[ 
https://issues.apache.org/jira/browse/KYLIN-3597?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16722151#comment-16722151
 ] 

ASF GitHub Bot commented on KYLIN-3597:
---------------------------------------

shaofengshi closed pull request #392: KYLIN-3597 fix sonar issues
URL: https://github.com/apache/kylin/pull/392
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/core-common/src/main/java/org/apache/kylin/common/util/SSHClient.java 
b/core-common/src/main/java/org/apache/kylin/common/util/SSHClient.java
index 26729207bb..b5d645952c 100644
--- a/core-common/src/main/java/org/apache/kylin/common/util/SSHClient.java
+++ b/core-common/src/main/java/org/apache/kylin/common/util/SSHClient.java
@@ -42,6 +42,7 @@
 
 public class SSHClient {
     protected static final org.slf4j.Logger logger = 
LoggerFactory.getLogger(SSHClient.class);
+    private static final String ERROR_IN_CHECK_ACK = "Error in checkAck()";
 
     private String hostname;
     private int port;
@@ -97,7 +98,7 @@ public void scpFileToRemote(String localFile, String 
remoteTargetDirectory) thro
                 out.write(command.getBytes(StandardCharsets.UTF_8));
                 out.flush();
                 if (checkAck(in) != 0) {
-                    throw new Exception("Error in checkAck()");
+                    throw new Exception(ERROR_IN_CHECK_ACK);
                 }
             }
 
@@ -115,7 +116,7 @@ public void scpFileToRemote(String localFile, String 
remoteTargetDirectory) thro
             out.write(command.getBytes(StandardCharsets.UTF_8));
             out.flush();
             if (checkAck(in) != 0) {
-                throw new Exception("Error in checkAck()");
+                throw new Exception(ERROR_IN_CHECK_ACK);
             }
 
             // send a content of lfile
@@ -134,7 +135,7 @@ public void scpFileToRemote(String localFile, String 
remoteTargetDirectory) thro
             out.write(buf, 0, 1);
             out.flush();
             if (checkAck(in) != 0) {
-                throw new Exception("Error in checkAck()");
+                throw new Exception(ERROR_IN_CHECK_ACK);
             }
             out.close();
 
diff --git 
a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidRecommender.java
 
b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidRecommender.java
index 057f7e84e2..54c6764023 100644
--- 
a/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidRecommender.java
+++ 
b/core-cube/src/main/java/org/apache/kylin/cube/cuboid/algorithm/CuboidRecommender.java
@@ -20,6 +20,7 @@
 
 import java.io.IOException;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
@@ -97,20 +98,20 @@ public static CuboidRecommender getInstance() {
                                     true);
 
                             if (recommendCuboid != null) {
-                                logger.info("Add recommend cuboids for " + key 
+ " to cache");
+                                logger.info(String.format(Locale.ROOT, "Add 
recommend cuboids for %s to cache", key));
                                 cuboidRecommendCache.put(key, recommendCuboid);
                             }
 
                             return recommendCuboid;
                         } catch (Exception e) {
                             cuboidRecommendCache.invalidate(key);
-                            logger.error("Failed to get recommend cuboids for 
" + key + " in cache", e);
+                            logger.error(String.format(Locale.ROOT, "Failed to 
get recommend cuboids for %s in cache", key), e);
                             throw e;
                         }
                     }
                 });
             } catch (ExecutionException e) {
-                logger.error("Failed to get recommend cuboids for " + key);
+                logger.error(String.format(Locale.ROOT, "Failed to get 
recommend cuboids for %s", key));
             }
         }
         return results;
@@ -121,9 +122,9 @@ public static CuboidRecommender getInstance() {
      */
     public Map<Long, Long> getRecommendCuboidList(CuboidStats cuboidStats, 
KylinConfig kylinConf,
             boolean ifForceRecommend) {
-        long Threshold1 = 1L << 
kylinConf.getCubePlannerAgreedyAlgorithmAutoThreshold();
-        long Threshold2 = 1L << 
kylinConf.getCubePlannerGeneticAlgorithmAutoThreshold();
-        if (Threshold1 >= Threshold2) {
+        long threshold1 = 1L << 
kylinConf.getCubePlannerAgreedyAlgorithmAutoThreshold();
+        long threshold2 = 1L << 
kylinConf.getCubePlannerGeneticAlgorithmAutoThreshold();
+        if (threshold1 >= threshold2) {
             logger.error("Invalid Cube Planner Algorithm configuration");
             return null;
         }
@@ -134,7 +135,7 @@ public static CuboidRecommender getInstance() {
         BenefitPolicy benefitPolicy = new PBPUSCalculator(cuboidStats);
         CuboidRecommendAlgorithm algorithm = null;
 
-        if (allCuboidCount <= Threshold2) {
+        if (allCuboidCount <= threshold2) {
             algorithm = new GreedyAlgorithm(-1, benefitPolicy, cuboidStats);
         } else {
             algorithm = new GeneticAlgorithm(-1, benefitPolicy, cuboidStats);
@@ -161,7 +162,7 @@ public static CuboidRecommender getInstance() {
             }
         }
 
-        if (!ifForceRecommend && allCuboidCount <= Threshold1) {
+        if (!ifForceRecommend && allCuboidCount <= threshold1) {
             return null;
         }
         return recommendCuboidsWithStats;
diff --git 
a/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/CubeScanRangePlanner.java
 
b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/CubeScanRangePlanner.java
index 229ef01790..1a02e1aa3a 100644
--- 
a/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/CubeScanRangePlanner.java
+++ 
b/core-storage/src/main/java/org/apache/kylin/storage/gtrecord/CubeScanRangePlanner.java
@@ -167,7 +167,7 @@ public CubeScanRangePlanner(GTInfo info, TblColRef 
gtPartitionCol, TupleFilter g
     public GTScanRequest planScanRequest() {
         GTScanRequest scanRequest;
         List<GTScanRange> scanRanges = this.planScanRanges();
-        if (scanRanges != null && scanRanges.size() != 0) {
+        if (scanRanges != null && !scanRanges.isEmpty()) {
             scanRequest = new 
GTScanRequestBuilder().setInfo(gtInfo).setRanges(scanRanges).setDimensions(gtDimensions)
                     
.setAggrGroupBy(gtAggrGroups).setAggrMetrics(gtAggrMetrics).setAggrMetricsFuncs(gtAggrFuncs)
                     .setFilterPushDown(gtFilter)//
@@ -260,10 +260,6 @@ protected GTScanRange newScanRange(Collection<ColumnRange> 
andDimRanges) {
         List<Map<Integer, ByteArray>> fuzzyValueCombinations = 
FuzzyValueCombination.calculate(fuzzyValueSet, maxFuzzyKeys);
         for (Map<Integer, ByteArray> fuzzyValue : fuzzyValueCombinations) {
 
-            //            BitSet bitSet = new BitSet(gtInfo.getColumnCount());
-            //            for (Map.Entry<Integer, ByteArray> entry : 
fuzzyValue.entrySet()) {
-            //                bitSet.set(entry.getKey());
-            //            }
             GTRecord fuzzy = new GTRecord(gtInfo);
             for (Map.Entry<Integer, ByteArray> entry : fuzzyValue.entrySet()) {
                 fuzzy.set(entry.getKey(), entry.getValue());
@@ -374,7 +370,7 @@ private GTScanRange mergeKeyRange(List<GTScanRange> ranges) 
{
                     result.add(new GTScanRange(range.pkStart, range.pkEnd, 
subFuzzyKeys));
                     startIndex = endIndex;
                 }
-                logger.debug("large FuzzyKeys split size : " + result.size());
+                logger.debug("large FuzzyKeys split size : {0}", 
result.size());
             } else {
                 result.add(range);
             }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Fix sonar reported static code issues
> -------------------------------------
>
>                 Key: KYLIN-3597
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3597
>             Project: Kylin
>          Issue Type: Improvement
>          Components: Others
>            Reporter: Shaofeng SHI
>            Priority: Major
>             Fix For: v2.6.0
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to