Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sonar] Fix Codesmell blocker and critical issue #1750

Merged
merged 21 commits into from
Oct 14, 2020

Conversation

DidierDrogba1
Copy link
Contributor

  1. Rename variable
  2. Define a constant name for repeated strings

@@ -90,55 +91,55 @@ public Object deserialize(List<String> columnNames, List<TypeInfo> columnTypes,
row.add(((BooleanWritable)data).get());
}
else {
throw new TsFileSerDeException("Unexpected data type: " + data.getClass().getName() + " for Date TypeInfo: " + type);
throw new TsFileSerDeException(UNEXPECTED_DATA_TYPE + data.getClass().getName() + FOR_DATE_TYPEINFO + type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String.format("Unexpected data type: %s for Date TypeInfo: %s", data.getClass().getName(), type)

@@ -112,7 +112,7 @@
private long displayIntervalInMs;
private Map<String, Boolean> operationSwitch;

private static final Logger LOGGER = LoggerFactory.getLogger(Measurement.class);
private static final Logger LOG = LoggerFactory.getLogger(Measurement.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change this name?

@@ -26,23 +26,23 @@

public class JvmSource implements Source {

public String sourceName = "jvm";
public String SOURCE_NAME = "jvm";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public final static String ?

@@ -24,7 +24,7 @@

public class MetricsSource implements Source {

public String sourceName = "iot-metrics";
public String SOURCE_NAME = "iot-metrics";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final static String

Copy link
Contributor

@wshao08 wshao08 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! Please fix following issues.

if (tmpLogFile.exists()) {
if (!tmpLogFile.delete()) {
if (tmpLogFile.exists() && !tmpLogFile.delete()) {
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this pair of parentheses

if (hasLimit) {
if (count.get().intValue() == limit.get().intValue()) {
if (hasLimit && count.get().intValue() == limit.get().intValue()) {
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this parentheses

@@ -26,23 +26,23 @@

public class JvmSource implements Source {

public String sourceName = "jvm";
public final static String SOURCE_NAME = "jvm";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public static final

@@ -41,6 +42,7 @@
* @param name CompressionType
* @return the UnCompressor of specified CompressionType
*/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove blank line

@@ -200,6 +200,9 @@
private UpdateOperator updateOp;
private QueryOperator queryOp;
private DeleteDataOperator deleteDataOp;
private static final String FOR_DELETE_STATEMENT = "For delete statement, where clause can only contain atomic expressions like : ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine to one error message. Call it "DELETE_RANGE_ERROR_MSG"

@@ -36,6 +36,9 @@

private Binary firstValue = new Binary("");
private Binary lastValue = new Binary("");
private static final String BINARY_STATISTICS_NOT_SUPPORT_MIN = "Binary statistics does not support: min";
private static final String BINARY_STATISTICS_NOT_SUPPORT_MAX = "Binary statistics does not support: max";
private static final String BINARY_STATISTICS_NOT_SUPPORT_SUM = "Binary statistics does not support: sum";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use BINARY_STATS_UNSUPPORTED_MSG to represent "Binary statistics does not support: %s",
and use String.format(BINARY_STATS_UNSUPPORTED_MSG, "min");

throw new RuntimeException("can not delete " + f.getAbsolutePath());
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove blank line and set indentation to 2

@@ -129,10 +129,8 @@ private RowRecord constructRowRecordFromValueArray() throws StatementExecutionEx


public RowRecord next() throws StatementExecutionException, IoTDBConnectionException {
if (!ioTDBRpcDataSet.hasCachedRecord) {
if (!hasNext()) {
if (!ioTDBRpcDataSet.hasCachedRecord && !hasNext()) {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set indentation to 2

Copy link
Contributor

@wshao08 wshao08 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@HTHou HTHou mentioned this pull request Oct 12, 2020
@HTHou HTHou merged commit a1adaf2 into apache:master Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants