-
Notifications
You must be signed in to change notification settings - Fork 966
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
Conversation
DidierDrogba1
commented
Sep 22, 2020
- Rename variable
- Define a constant name for repeated strings
tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/Decoder.java
Outdated
Show resolved
Hide resolved
hive-connector/src/main/java/org/apache/iotdb/hive/TsFileDeserializer.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/qp/strategy/LogicalGenerator.java
Outdated
Show resolved
Hide resolved
@@ -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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final static String
There was a problem hiding this 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()) { | ||
{ |
There was a problem hiding this comment.
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()) { | ||
{ |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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 | |||
*/ | |||
|
There was a problem hiding this comment.
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 : "; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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()); | ||
} | ||
|
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set indentation to 2
There was a problem hiding this 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
server/src/main/java/org/apache/iotdb/db/engine/fileSystem/SystemFileFactory.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metrics/source/JvmSource.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metrics/ui/MetricsPage.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/query/control/TracingManager.java
Outdated
Show resolved
Hide resolved
5c1697c
to
1ab1874
Compare