]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some quality flaws 462/head
authorJulien HENRY <julien.henry@sonarsource.com>
Wed, 5 Aug 2015 08:34:26 +0000 (10:34 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Wed, 5 Aug 2015 11:52:59 +0000 (13:52 +0200)
39 files changed:
plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java
plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java
plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java
plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/MultilineIssuesSensor.java
plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssueOnDirPerFileSensor.java
plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/RandomAccessSensor.java
server/sonar-server/src/main/java/org/sonar/server/batch/IssuesAction.java
server/sonar-server/src/main/java/org/sonar/server/batch/ProjectRepositoryLoader.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java
server/sonar-server/src/main/java/org/sonar/server/permission/PermissionTemplateService.java
sonar-batch/src/main/java/org/sonar/batch/ProfileLoader.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/index/Data.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/index/ResourceNotPersistedException.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/index/StringData.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/issue/DeprecatedIssueWrapper.java
sonar-batch/src/main/java/org/sonar/batch/issue/IssueFilters.java
sonar-batch/src/main/java/org/sonar/batch/issue/ModuleIssues.java
sonar-batch/src/main/java/org/sonar/batch/issue/tracking/IssueTracking.java
sonar-batch/src/main/java/org/sonar/batch/issue/tracking/IssueTrackingResult.java
sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java
sonar-batch/src/main/java/org/sonar/batch/issue/tracking/ServerIssueRepository.java
sonar-batch/src/main/java/org/sonar/batch/report/ComponentsPublisher.java
sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileProvider.java
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorBuilder.java
sonar-batch/src/main/java/org/sonar/batch/scan/ProjectReactorValidator.java
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/DefaultModuleFileSystem.java
sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/FileSystemLogger.java
sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java
sonar-batch/src/main/java/org/sonar/batch/scan/report/ConsoleReport.java
sonar-batch/src/main/java/org/sonar/batch/scan/report/IssuesReportBuilder.java
sonar-batch/src/main/java/org/sonar/batch/scan/report/RuleReportComparator.java
sonar-batch/src/main/java/org/sonar/batch/scan/report/SourceProvider.java
sonar-batch/src/main/java/org/sonar/batch/scm/DefaultBlameOutput.java
sonar-batch/src/main/java/org/sonar/batch/scm/ScmSensor.java
sonar-batch/src/main/java/org/sonar/batch/sensor/coverage/CoverageExclusions.java
sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestable.java
sonar-core/src/main/java/org/sonar/core/issue/DefaultIssue.java
sonar-db/src/main/java/org/sonar/db/version/SelectImpl.java
sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/issue/internal/DefaultIssue.java

index e69aa54c21075bef575fc644fed81f10929e5dae..66573470ddbe0e517bbdf7a9cbfc989364414012 100644 (file)
 package org.sonar.xoo.lang;
 
 import com.google.common.base.Splitter;
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.sonar.api.batch.fs.InputFile;
@@ -33,11 +37,6 @@ import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.xoo.Xoo;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
 /**
  * Parse files *.xoo.symbol
  */
@@ -79,7 +78,7 @@ public class SymbolReferencesSensor implements Sensor {
     }
   }
 
-  private void processLine(File symbolFile, int lineNumber, Symbolizable.SymbolTableBuilder symbolTableBuilder, String line) {
+  private static void processLine(File symbolFile, int lineNumber, Symbolizable.SymbolTableBuilder symbolTableBuilder, String line) {
     try {
       Iterator<String> split = Splitter.on(",").split(line).iterator();
       int startOffset = Integer.parseInt(split.next());
index bd273dec4ffdac330331900f9e9edd36a4741375..a059d8b26bec5b395d2fbf2977fdfd2f8ba17e1c 100644 (file)
 package org.sonar.xoo.lang;
 
 import com.google.common.base.Splitter;
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.sonar.api.batch.fs.InputFile;
@@ -32,11 +36,6 @@ import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.xoo.Xoo;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
 /**
  * Parse files *.xoo.highlighting
  */
@@ -69,7 +68,7 @@ public class SyntaxHighlightingSensor implements Sensor {
     }
   }
 
-  private void processLine(File highlightingFile, int lineNumber, NewHighlighting highlightingBuilder, String line) {
+  private static void processLine(File highlightingFile, int lineNumber, NewHighlighting highlightingBuilder, String line) {
     try {
       Iterator<String> split = Splitter.on(":").split(line).iterator();
       int startOffset = Integer.parseInt(split.next());
index e92e5c1256432b0fc2ba56b14f862762e0cecbf8..cbff8a7e1f6f547801cc864f64c7ec72421ed6ae 100644 (file)
@@ -51,7 +51,7 @@ public class CreateIssueByInternalKeySensor implements Sensor {
     }
   }
 
-  private void createIssues(InputFile file, SensorContext context) {
+  private static void createIssues(InputFile file, SensorContext context) {
     ActiveRule rule = context.activeRules().findByInternalKey(XooRulesDefinition.XOO_REPOSITORY,
       context.settings().getString(INTERNAL_KEY_PROPERTY));
     if (rule != null) {
index 57dbc84464be08d6e9f50ab39974ad4670d41679..81891faf809154ee18d93d1449e03d115dbe703c 100644 (file)
@@ -61,13 +61,38 @@ public class MultilineIssuesSensor implements Sensor {
     }
   }
 
-  private void createIssues(InputFile file, SensorContext context) {
+  private static void createIssues(InputFile file, SensorContext context) {
     Pattern startPattern = Pattern.compile(START_ISSUE_PATTERN);
     Pattern endPattern = Pattern.compile(END_ISSUE_PATTERN);
     Map<Integer, Map<Integer, TextPointer>> startPositions = new HashMap<>();
     Map<Integer, Map<Integer, TextPointer>> endPositions = new HashMap<>();
 
     RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY);
+    parse(file, context, startPattern, endPattern, startPositions, endPositions);
+    createIssues(file, context, startPositions, endPositions, ruleKey);
+  }
+
+  private static void createIssues(InputFile file, SensorContext context, Map<Integer, Map<Integer, TextPointer>> startPositions,
+    Map<Integer, Map<Integer, TextPointer>> endPositions,
+    RuleKey ruleKey) {
+    for (Map.Entry<Integer, Map<Integer, TextPointer>> entry : startPositions.entrySet()) {
+      NewIssue newIssue = context.newIssue().forRule(ruleKey);
+      for (Map.Entry<Integer, TextPointer> location : entry.getValue().entrySet()) {
+        NewIssueLocation newLocation = newIssue.newLocation()
+          .on(file)
+          .at(file.newRange(location.getValue(), endPositions.get(entry.getKey()).get(location.getKey())));
+        if (location.getKey() == 1) {
+          newIssue.at(newLocation.message("Primary location"));
+        } else {
+          newIssue.addLocation(newLocation.message("Location #" + location.getKey()));
+        }
+      }
+      newIssue.save();
+    }
+  }
+
+  private static void parse(InputFile file, SensorContext context, Pattern startPattern, Pattern endPattern, Map<Integer, Map<Integer, TextPointer>> startPositions,
+    Map<Integer, Map<Integer, TextPointer>> endPositions) {
     int currentLine = 0;
     try {
       for (String lineStr : Files.readAllLines(file.path(), context.fileSystem().encoding())) {
@@ -98,20 +123,6 @@ public class MultilineIssuesSensor implements Sensor {
     } catch (IOException e) {
       throw new IllegalStateException("Unable to read file", e);
     }
-    for (Map.Entry<Integer, Map<Integer, TextPointer>> entry : startPositions.entrySet()) {
-      NewIssue newIssue = context.newIssue().forRule(ruleKey);
-      for (Map.Entry<Integer, TextPointer> location : entry.getValue().entrySet()) {
-        NewIssueLocation newLocation = newIssue.newLocation()
-          .on(file)
-          .at(file.newRange(location.getValue(), endPositions.get(entry.getKey()).get(location.getKey())));
-        if (location.getKey() == 1) {
-          newIssue.at(newLocation.message("Primary location"));
-        } else {
-          newIssue.addLocation(newLocation.message("Location #" + location.getKey()));
-        }
-      }
-      newIssue.save();
-    }
   }
 
 }
index b2d047a99940229473372194f35c3fbddbf26a6e..e3a7b30d3d22b809a7061dd88bd41640e5a0b3e2 100644 (file)
@@ -47,7 +47,7 @@ public class OneIssueOnDirPerFileSensor implements Sensor {
     }
   }
 
-  private void createIssues(InputFile file, SensorContext context) {
+  private static void createIssues(InputFile file, SensorContext context) {
     RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY);
     InputDir inputDir = context.fileSystem().inputDir(file.file().getParentFile());
     if (inputDir != null) {
index bc7b90a69ae06f55624d272daf94b71c9891b127..94cc2144387e940f9dfa118dbec475ead4238f61 100644 (file)
@@ -61,7 +61,7 @@ public class RandomAccessSensor implements Sensor {
     }
   }
 
-  private void createIssues(InputFile file, SensorContext context) {
+  private static void createIssues(InputFile file, SensorContext context) {
     RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY);
     NewIssue newIssue = context.newIssue();
     newIssue
index 64d7e0a7e0eec448edd4256d9a394db6444a432e..6e3042a4d931a32fb3160ad7d4c4cdb6e40a32ae 100644 (file)
@@ -86,7 +86,7 @@ public class IssuesAction implements BatchWsAction {
       Map<String, String> keysByUUid = keysByUUid(session, component);
 
       BatchInput.ServerIssue.Builder issueBuilder = BatchInput.ServerIssue.newBuilder();
-      for (Iterator<IssueDoc> issueDocIterator = issueIndex.selectIssuesForBatch(component); issueDocIterator.hasNext(); ) {
+      for (Iterator<IssueDoc> issueDocIterator = issueIndex.selectIssuesForBatch(component); issueDocIterator.hasNext();) {
         handleIssue(issueDocIterator.next(), issueBuilder, keysByUUid, response.stream().output());
       }
     } finally {
@@ -94,7 +94,7 @@ public class IssuesAction implements BatchWsAction {
     }
   }
 
-  private void handleIssue(IssueDoc issue, BatchInput.ServerIssue.Builder issueBuilder, Map<String, String> keysByUUid, OutputStream out) {
+  private static void handleIssue(IssueDoc issue, BatchInput.ServerIssue.Builder issueBuilder, Map<String, String> keysByUUid, OutputStream out) {
     issueBuilder.setKey(issue.key());
     issueBuilder.setModuleKey(keysByUUid.get(issue.moduleUuid()));
     String path = issue.filePath();
index 63d8ad433f95cc499c284635a4b68731bcf8c53d..e520ecf1e078190a590698687523a39213aafe90 100644 (file)
@@ -77,7 +77,7 @@ public class ProjectRepositoryLoader {
   private final UserSession userSession;
 
   public ProjectRepositoryLoader(DbClient dbClient, QProfileFactory qProfileFactory, QProfileLoader qProfileLoader, RuleService ruleService,
-                                 Languages languages, UserSession userSession) {
+    Languages languages, UserSession userSession) {
     this.dbClient = dbClient;
     this.qProfileFactory = qProfileFactory;
     this.qProfileLoader = qProfileLoader;
@@ -117,9 +117,8 @@ public class ProjectRepositoryLoader {
         TreeModuleSettings treeModuleSettings = new TreeModuleSettings(moduleUuidsByKey, moduleIdsByKey, modulesTree, modulesTreeSettings, module);
 
         addSettingsToChildrenModules(ref, query.getModuleKey(), Maps.<String, String>newHashMap(), treeModuleSettings, hasScanPerm, session);
-        List<FilePathWithHashDto> files = module.isRootProject() ?
-          dbClient.componentDao().selectEnabledFilesFromProject(session, module.uuid()) :
-          dbClient.componentDao().selectEnabledDescendantFiles(session, module.uuid());
+        List<FilePathWithHashDto> files = module.isRootProject() ? dbClient.componentDao().selectEnabledFilesFromProject(session, module.uuid())
+          : dbClient.componentDao().selectEnabledDescendantFiles(session, module.uuid());
         addFileData(session, ref, modulesTree, files);
 
         // FIXME need real value but actually only used to know if there is a previous analysis in local issue tracking mode so any value is
@@ -170,7 +169,7 @@ public class ProjectRepositoryLoader {
   }
 
   private void addSettingsToChildrenModules(ProjectRepositories ref, String moduleKey, Map<String, String> parentProperties, TreeModuleSettings treeModuleSettings,
-                                            boolean hasScanPerm, DbSession session) {
+    boolean hasScanPerm, DbSession session) {
     Map<String, String> currentParentProperties = newHashMap();
     currentParentProperties.putAll(parentProperties);
     currentParentProperties.putAll(getPropertiesMap(treeModuleSettings.findModuleSettings(moduleKey), hasScanPerm));
@@ -182,7 +181,7 @@ public class ProjectRepositoryLoader {
     }
   }
 
-  private void addSettings(ProjectRepositories ref, String module, Map<String, String> properties) {
+  private static void addSettings(ProjectRepositories ref, String module, Map<String, String> properties) {
     if (!properties.isEmpty()) {
       ref.addSettings(module, properties);
     }
@@ -241,10 +240,10 @@ public class ProjectRepositoryLoader {
       // Load all rules of the profile language (only needed fields are loaded)
       Map<RuleKey, Rule> languageRules = ruleByRuleKey(ruleService.search(new RuleQuery().setLanguages(newArrayList(qProfile.language())),
         new QueryContext(userSession).setLimit(100).setFieldsToReturn(newArrayList(
-          RuleNormalizer.RuleField.KEY.field(), RuleNormalizer.RuleField.NAME.field(), RuleNormalizer.RuleField.INTERNAL_KEY.field(), RuleNormalizer.RuleField.TEMPLATE_KEY.field()
-        )).setScroll(true))
+          RuleNormalizer.RuleField.KEY.field(), RuleNormalizer.RuleField.NAME.field(), RuleNormalizer.RuleField.INTERNAL_KEY.field(),
+          RuleNormalizer.RuleField.TEMPLATE_KEY.field())).setScroll(true))
         .scroll());
-      for (Iterator<ActiveRule> activeRuleIterator = qProfileLoader.findActiveRulesByProfile(qProfile.key()); activeRuleIterator.hasNext(); ) {
+      for (Iterator<ActiveRule> activeRuleIterator = qProfileLoader.findActiveRulesByProfile(qProfile.key()); activeRuleIterator.hasNext();) {
         ActiveRule activeRule = activeRuleIterator.next();
         Rule rule = languageRules.get(activeRule.key().ruleKey());
         if (rule == null) {
@@ -339,7 +338,7 @@ public class ProjectRepositoryLoader {
     private Multimap<String, ComponentDto> moduleChildrenByModuleUuid;
 
     private TreeModuleSettings(Map<String, String> moduleUuidsByKey, Map<String, Long> moduleIdsByKey, List<ComponentDto> moduleChildren,
-                               List<PropertyDto> moduleChildrenSettings, ComponentDto module) {
+      List<PropertyDto> moduleChildrenSettings, ComponentDto module) {
       this.moduleIdsByKey = moduleIdsByKey;
       this.moduleUuidsByKey = moduleUuidsByKey;
       propertiesByModuleId = ArrayListMultimap.create();
index f3e16c808b4b9d7be73a60d95e6e84274e1eb185..df21cfbb5fa0d27fe5cfdb05645be388c158d491 100644 (file)
@@ -67,8 +67,8 @@ import org.sonar.api.resources.Scopes;
 import org.sonar.api.rule.Severity;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
-import org.sonar.db.component.ComponentDto;
 import org.sonar.core.util.NonNullInputFunction;
+import org.sonar.db.component.ComponentDto;
 import org.sonar.server.es.BaseIndex;
 import org.sonar.server.es.EsClient;
 import org.sonar.server.es.EsUtils;
@@ -92,7 +92,6 @@ import static com.google.common.collect.Lists.newArrayList;
  */
 public class IssueIndex extends BaseIndex {
 
-
   private static final String SUBSTRING_MATCH_REGEXP = ".*%s.*";
 
   public static final List<String> SUPPORTED_FACETS = ImmutableList.of(
@@ -326,7 +325,7 @@ public class IssueIndex extends BaseIndex {
     return String.format("%s%s%s", IssueIndexDefinition.TYPE_ISSUE, viewUuid, ViewIndexDefinition.TYPE_VIEW);
   }
 
-  private FilterBuilder createAuthorizationFilter(boolean checkAuthorization, @Nullable String userLogin, Set<String> userGroups) {
+  private static FilterBuilder createAuthorizationFilter(boolean checkAuthorization, @Nullable String userLogin, Set<String> userGroups) {
     if (checkAuthorization) {
       OrFilterBuilder groupsAndUser = FilterBuilders.orFilter();
       if (userLogin != null) {
@@ -340,8 +339,7 @@ public class IssueIndex extends BaseIndex {
           QueryBuilders.matchAllQuery(),
           FilterBuilders.boolFilter()
             .must(groupsAndUser)
-            .cache(true))
-        );
+            .cache(true)));
     } else {
       return FilterBuilders.matchAllFilter();
     }
@@ -533,8 +531,7 @@ public class IssueIndex extends BaseIndex {
     facetTopAggregation.subAggregation(
       addDebtAggregationIfNeeded(query, AggregationBuilders
         .missing(facetName + FACET_SUFFIX_MISSING)
-        .field(fieldName))
-      );
+        .field(fieldName)));
 
     return AggregationBuilders
       .global(facetName)
@@ -543,11 +540,11 @@ public class IssueIndex extends BaseIndex {
 
   private Collection<String> escapeValuesForFacetInclusion(@Nullable Collection<String> values) {
     return values == null ? Arrays.<String>asList() : Collections2.transform(values, new Function<String, String>() {
-        @Override
-        public String apply(String input) {
-          return Pattern.quote(input);
-        }
-      });
+      @Override
+      public String apply(String input) {
+        return Pattern.quote(input);
+      }
+    });
   }
 
   private void addAssignedToMeFacetIfNeeded(SearchRequestBuilder builder, SearchOptions options, IssueQuery query, Map<String, FilterBuilder> filters, QueryBuilder queryBuilder) {
@@ -591,8 +588,7 @@ public class IssueIndex extends BaseIndex {
     facetTopAggregation.subAggregation(
       addDebtAggregationIfNeeded(query, AggregationBuilders
         .missing(facetName + FACET_SUFFIX_MISSING)
-        .field(fieldName))
-      );
+        .field(fieldName)));
 
     return AggregationBuilders
       .global(facetName)
@@ -616,8 +612,7 @@ public class IssueIndex extends BaseIndex {
     facetTopAggregation.subAggregation(
       addDebtAggregationIfNeeded(query, AggregationBuilders
         .missing(facetName + FACET_SUFFIX_MISSING)
-        .field(fieldName))
-      );
+        .field(fieldName)));
 
     return AggregationBuilders
       .global(facetName)
@@ -711,8 +706,7 @@ public class IssueIndex extends BaseIndex {
     FilterBuilder dateFilter = FilterBuilders.rangeFilter(IssueIndexDefinition.FIELD_ISSUE_FUNC_CLOSED_AT).lt(beforeDate.getTime());
     QueryBuilder queryBuilder = QueryBuilders.filteredQuery(
       QueryBuilders.matchAllQuery(),
-      FilterBuilders.andFilter(projectFilter, dateFilter)
-      );
+      FilterBuilders.andFilter(projectFilter, dateFilter));
 
     getClient().prepareDeleteByQuery(IssueIndexDefinition.INDEX).setQuery(queryBuilder).get();
   }
index 5c17afae00751c397332225a38a00334672fc793..05cbdac7e3f8e188d738cf204058310dca2670a9 100644 (file)
 package org.sonar.server.permission;
 
 import com.google.common.collect.Lists;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.server.ServerSide;
 import org.sonar.core.permission.GlobalPermissions;
-import org.sonar.db.permission.PermissionTemplateDao;
-import org.sonar.db.permission.PermissionTemplateDto;
 import org.sonar.db.DbSession;
 import org.sonar.db.MyBatis;
+import org.sonar.db.permission.PermissionTemplateDao;
+import org.sonar.db.permission.PermissionTemplateDto;
 import org.sonar.db.user.GroupDto;
 import org.sonar.db.user.UserDao;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.exceptions.NotFoundException;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
 import org.sonar.server.user.UserSession;
 
 /**
@@ -188,7 +186,7 @@ public class PermissionTemplateService {
     }
   }
 
-  private void validateKeyPattern(@Nullable String keyPattern) {
+  private static void validateKeyPattern(@Nullable String keyPattern) {
     if (StringUtils.isEmpty(keyPattern)) {
       return;
     }
diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProfileLoader.java b/sonar-batch/src/main/java/org/sonar/batch/ProfileLoader.java
deleted file mode 100644 (file)
index bc00a1c..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch;
-
-import org.sonar.api.config.Settings;
-import org.sonar.api.profiles.RulesProfile;
-
-/**
- * This interface is implemented by the views plugin!!
- *
- * @deprecated in 4.2
- */
-@Deprecated
-public interface ProfileLoader {
-
-  /**
-   * Loads quality profile for specified project.
-   */
-  RulesProfile load(Settings settings);
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/Data.java b/sonar-batch/src/main/java/org/sonar/batch/index/Data.java
deleted file mode 100644 (file)
index aa47c04..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.index;
-
-import java.io.Serializable;
-
-public interface Data extends Serializable {
-
-  String writeString();
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ResourceNotPersistedException.java b/sonar-batch/src/main/java/org/sonar/batch/index/ResourceNotPersistedException.java
deleted file mode 100644 (file)
index 1cf29c6..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.index;
-
-import org.sonar.api.resources.Resource;
-import org.sonar.api.utils.SonarException;
-
-/**
- * @since 2.6
- */
-public final class ResourceNotPersistedException extends SonarException {
-
-  public ResourceNotPersistedException(Resource resource) {
-    super(resource.toString());
-  }
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/StringData.java b/sonar-batch/src/main/java/org/sonar/batch/index/StringData.java
deleted file mode 100644 (file)
index 6a88b59..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.batch.index;
-
-public class StringData implements Data {
-  private String data = null;
-
-  public StringData() {
-  }
-
-  public StringData(String s) {
-    this.data = s;
-  }
-
-  public String data() {
-    return data;
-  }
-
-  @Override
-  public String writeString() {
-    return data;
-  }
-}
index 752e1e92d2fb660a7a03dc7c120f20da47a990f6..d1d2efdf8f10e37b761b104858b258461e7206e6 100644 (file)
@@ -20,6 +20,7 @@
 package org.sonar.batch.issue;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -142,7 +143,7 @@ public class DeprecatedIssueWrapper implements Issue {
 
   @Override
   public List<IssueComment> comments() {
-    return null;
+    return Collections.emptyList();
   }
 
   @Override
@@ -172,7 +173,7 @@ public class DeprecatedIssueWrapper implements Issue {
 
   @Override
   public Collection<String> tags() {
-    return null;
+    return Collections.emptyList();
   }
 
 }
index ed609db03704ad4866e38b6ba52c657944f27b74..093cef7135583514b7402f14af729e148e08c81a 100644 (file)
@@ -37,181 +37,186 @@ import org.sonar.batch.protocol.output.BatchReport;
 @BatchSide
 public class IssueFilters {
 
-  private final org.sonar.api.issue.IssueFilter[] exclusionFilters;
-  private final IssueFilter[] filters;
-  private final Project project;
+  private static final class IssueAdapterForFilter implements Issue {
+    private final Project project;
+    private final org.sonar.batch.protocol.output.BatchReport.Issue rawIssue;
+    private final String componentKey;
+
+    private IssueAdapterForFilter(Project project, org.sonar.batch.protocol.output.BatchReport.Issue rawIssue, String componentKey) {
+      this.project = project;
+      this.rawIssue = rawIssue;
+      this.componentKey = componentKey;
+    }
 
-  public IssueFilters(Project project, org.sonar.api.issue.IssueFilter[] exclusionFilters, IssueFilter[] filters) {
-    this.project = project;
-    this.exclusionFilters = exclusionFilters;
-    this.filters = filters;
-  }
+    @Override
+    public String key() {
+      throw unsupported();
+    }
 
-  public IssueFilters(Project project, org.sonar.api.issue.IssueFilter[] exclusionFilters) {
-    this(project, exclusionFilters, new IssueFilter[0]);
-  }
+    @Override
+    public String componentKey() {
+      return componentKey;
+    }
 
-  public IssueFilters(Project project, IssueFilter[] filters) {
-    this(project, new org.sonar.api.issue.IssueFilter[0], filters);
-  }
+    @Override
+    public RuleKey ruleKey() {
+      return RuleKey.of(rawIssue.getRuleRepository(), rawIssue.getRuleKey());
+    }
 
-  public IssueFilters(Project project) {
-    this(project, new org.sonar.api.issue.IssueFilter[0], new IssueFilter[0]);
-  }
+    @Override
+    public String language() {
+      throw unsupported();
+    }
 
-  public boolean accept(String componentKey, BatchReport.Issue rawIssue) {
-    Issue issue = toIssueForIssueFilter(componentKey, rawIssue);
-    if (new DefaultIssueFilterChain(filters).accept(issue)) {
-      // Apply deprecated rules only if filter chain accepts the current issue
-      for (org.sonar.api.issue.IssueFilter filter : exclusionFilters) {
-        if (!filter.accept(issue)) {
-          return false;
-        }
-      }
-      return true;
-    } else {
-      return false;
+    @Override
+    public String severity() {
+      return rawIssue.getSeverity().name();
     }
-  }
 
-  private Issue toIssueForIssueFilter(final String componentKey, final BatchReport.Issue rawIssue) {
-    return new Issue() {
+    @Override
+    public String message() {
+      return rawIssue.getMsg();
+    }
 
-      @Override
-      public String key() {
-        throw unsupported();
-      }
+    @Override
+    public Integer line() {
+      return rawIssue.hasLine() ? rawIssue.getLine() : null;
+    }
 
-      @Override
-      public String componentKey() {
-        return componentKey;
-      }
+    @Override
+    public Double effortToFix() {
+      return rawIssue.hasEffortToFix() ? rawIssue.getEffortToFix() : null;
+    }
 
-      @Override
-      public RuleKey ruleKey() {
-        return RuleKey.of(rawIssue.getRuleRepository(), rawIssue.getRuleKey());
-      }
+    @Override
+    public String status() {
+      return Issue.STATUS_OPEN;
+    }
 
-      @Override
-      public String language() {
-        throw unsupported();
-      }
+    @Override
+    public String resolution() {
+      return null;
+    }
 
-      @Override
-      public String severity() {
-        return rawIssue.getSeverity().name();
-      }
+    @Override
+    public String reporter() {
+      throw unsupported();
+    }
 
-      @Override
-      public String message() {
-        return rawIssue.getMsg();
-      }
+    @Override
+    public String assignee() {
+      return null;
+    }
 
-      @Override
-      public Integer line() {
-        return rawIssue.hasLine() ? rawIssue.getLine() : null;
-      }
+    @Override
+    public Date creationDate() {
+      return project.getAnalysisDate();
+    }
 
-      @Override
-      public Double effortToFix() {
-        return rawIssue.hasEffortToFix() ? rawIssue.getEffortToFix() : null;
-      }
+    @Override
+    public Date updateDate() {
+      return null;
+    }
 
-      @Override
-      public String status() {
-        return Issue.STATUS_OPEN;
-      }
+    @Override
+    public Date closeDate() {
+      return null;
+    }
 
-      @Override
-      public String resolution() {
-        return null;
-      }
+    @Override
+    public String attribute(String key) {
+      return attributes().get(key);
+    }
 
-      @Override
-      public String reporter() {
-        throw unsupported();
-      }
+    @Override
+    public Map<String, String> attributes() {
+      return rawIssue.hasAttributes() ? KeyValueFormat.parse(rawIssue.getAttributes()) : Collections.<String, String>emptyMap();
+    }
 
-      @Override
-      public String assignee() {
-        return null;
-      }
+    @Override
+    public String authorLogin() {
+      throw unsupported();
+    }
 
-      @Override
-      public Date creationDate() {
-        return project.getAnalysisDate();
-      }
+    @Override
+    public String actionPlanKey() {
+      throw unsupported();
+    }
 
-      @Override
-      public Date updateDate() {
-        return null;
-      }
+    @Override
+    public List<IssueComment> comments() {
+      throw unsupported();
+    }
 
-      @Override
-      public Date closeDate() {
-        return null;
-      }
+    @Override
+    public boolean isNew() {
+      throw unsupported();
+    }
 
-      @Override
-      public String attribute(String key) {
-        return attributes().get(key);
-      }
+    @Override
+    public Duration debt() {
+      throw unsupported();
+    }
 
-      @Override
-      public Map<String, String> attributes() {
-        return rawIssue.hasAttributes() ? KeyValueFormat.parse(rawIssue.getAttributes()) : Collections.<String, String>emptyMap();
-      }
+    @Override
+    public String projectKey() {
+      return project.getEffectiveKey();
+    }
 
-      @Override
-      public String authorLogin() {
-        throw unsupported();
-      }
+    @Override
+    public String projectUuid() {
+      throw unsupported();
+    }
 
-      @Override
-      public String actionPlanKey() {
-        throw unsupported();
-      }
+    @Override
+    public String componentUuid() {
+      throw unsupported();
+    }
 
-      @Override
-      public List<IssueComment> comments() {
-        throw unsupported();
-      }
+    @Override
+    public Collection<String> tags() {
+      throw unsupported();
+    }
 
-      @Override
-      public boolean isNew() {
-        throw unsupported();
-      }
+    private static UnsupportedOperationException unsupported() {
+      return new UnsupportedOperationException("Not available for issues filters");
+    }
+  }
 
-      @Override
-      public Duration debt() {
-        throw unsupported();
-      }
+  private final org.sonar.api.issue.IssueFilter[] exclusionFilters;
+  private final IssueFilter[] filters;
+  private final Project project;
 
-      @Override
-      public String projectKey() {
-        return project.getEffectiveKey();
-      }
+  public IssueFilters(Project project, org.sonar.api.issue.IssueFilter[] exclusionFilters, IssueFilter[] filters) {
+    this.project = project;
+    this.exclusionFilters = exclusionFilters;
+    this.filters = filters;
+  }
 
-      @Override
-      public String projectUuid() {
-        throw unsupported();
-      }
+  public IssueFilters(Project project, org.sonar.api.issue.IssueFilter[] exclusionFilters) {
+    this(project, exclusionFilters, new IssueFilter[0]);
+  }
 
-      @Override
-      public String componentUuid() {
-        throw unsupported();
-      }
+  public IssueFilters(Project project, IssueFilter[] filters) {
+    this(project, new org.sonar.api.issue.IssueFilter[0], filters);
+  }
 
-      @Override
-      public Collection<String> tags() {
-        throw unsupported();
-      }
+  public IssueFilters(Project project) {
+    this(project, new org.sonar.api.issue.IssueFilter[0], new IssueFilter[0]);
+  }
 
-      private UnsupportedOperationException unsupported() {
-        return new UnsupportedOperationException("Not available for issues filters");
+  public boolean accept(String componentKey, BatchReport.Issue rawIssue) {
+    Issue issue = new IssueAdapterForFilter(project, rawIssue, componentKey);
+    if (new DefaultIssueFilterChain(filters).accept(issue)) {
+      // Apply deprecated rules only if filter chain accepts the current issue
+      for (org.sonar.api.issue.IssueFilter filter : exclusionFilters) {
+        if (!filter.accept(issue)) {
+          return false;
+        }
       }
-
-    };
-
+      return true;
+    } else {
+      return false;
+    }
   }
 }
index 67d3c98bb9438742fcee0a848b47c3742ce62aa6..4363a59853bcac7148ba53e89b3d30bf1e1ec613 100644 (file)
@@ -20,8 +20,8 @@
 package org.sonar.batch.issue;
 
 import com.google.common.base.Strings;
+import org.sonar.api.batch.fs.InputComponent;
 import org.sonar.api.batch.fs.TextRange;
-import org.sonar.api.batch.fs.internal.DefaultInputComponent;
 import org.sonar.api.batch.rule.ActiveRule;
 import org.sonar.api.batch.rule.ActiveRules;
 import org.sonar.api.batch.rule.Rule;
@@ -63,8 +63,8 @@ public class ModuleIssues {
   }
 
   public boolean initAndAddIssue(Issue issue) {
-    String key = ((DefaultInputComponent) issue.primaryLocation().inputComponent()).key();
-    BatchComponent component = componentCache.get(key);
+    InputComponent inputComponent = issue.primaryLocation().inputComponent();
+    BatchComponent component = componentCache.get(inputComponent);
 
     Rule rule = validateRule(issue);
     ActiveRule activeRule = activeRules.find(issue.ruleKey());
@@ -102,7 +102,7 @@ public class ModuleIssues {
     applyExecutionFlows(issue);
     BatchReport.Issue rawIssue = builder.build();
 
-    if (filters.accept(key, rawIssue)) {
+    if (filters.accept(inputComponent.key(), rawIssue)) {
       write(component, rawIssue);
       return true;
     }
@@ -112,8 +112,7 @@ public class ModuleIssues {
   private void applyAdditionalLocations(Issue issue) {
     for (org.sonar.api.batch.sensor.issue.IssueLocation additionalLocation : issue.locations()) {
       locationBuilder.clear();
-      String locationComponentKey = ((DefaultInputComponent) additionalLocation.inputComponent()).key();
-      locationBuilder.setComponentRef(componentCache.get(locationComponentKey).batchId());
+      locationBuilder.setComponentRef(componentCache.get(additionalLocation.inputComponent()).batchId());
       String message = additionalLocation.message();
       if (message != null) {
         locationBuilder.setMsg(message);
@@ -128,8 +127,7 @@ public class ModuleIssues {
       flowBuilder.clear();
       for (org.sonar.api.batch.sensor.issue.IssueLocation location : executionFlow.locations()) {
         locationBuilder.clear();
-        String locationComponentKey = ((DefaultInputComponent) location.inputComponent()).key();
-        locationBuilder.setComponentRef(componentCache.get(locationComponentKey).batchId());
+        locationBuilder.setComponentRef(componentCache.get(location.inputComponent()).batchId());
         String message = location.message();
         if (message != null) {
           locationBuilder.setMsg(message);
index 5ed488efedb39969a071f77d8db5b177506af7ca..b75d8501edbfd52ff35cb5cfe72ebb769ece6dc9 100644 (file)
@@ -226,7 +226,7 @@ public class IssueTracking {
     return rawIssuesByLines;
   }
 
-  private Multimap<Integer, ServerIssue> lastIssuesByLines(Collection<ServerIssue> previousIssues, IssueTrackingBlocksRecognizer rec) {
+  private static Multimap<Integer, ServerIssue> lastIssuesByLines(Collection<ServerIssue> previousIssues, IssueTrackingBlocksRecognizer rec) {
     Multimap<Integer, ServerIssue> previousIssuesByLines = LinkedHashMultimap.create();
     for (ServerIssue previousIssue : previousIssues) {
       if (rec.isValidLineInReference(previousIssue.line())) {
@@ -272,15 +272,15 @@ public class IssueTracking {
   }
 
   @CheckForNull
-  private Integer line(BatchReport.Issue rawIssue) {
+  private static Integer line(BatchReport.Issue rawIssue) {
     return rawIssue.hasLine() ? rawIssue.getLine() : null;
   }
 
-  private boolean isNotAlreadyMapped(ServerIssue previousIssue, IssueTrackingResult result) {
+  private static boolean isNotAlreadyMapped(ServerIssue previousIssue, IssueTrackingResult result) {
     return result.unmatched().contains(previousIssue);
   }
 
-  private boolean isNotAlreadyMapped(BatchReport.Issue rawIssue, IssueTrackingResult result) {
+  private static boolean isNotAlreadyMapped(BatchReport.Issue rawIssue, IssueTrackingResult result) {
     return !result.isMatched(rawIssue);
   }
 
@@ -297,11 +297,11 @@ public class IssueTracking {
   }
 
   @CheckForNull
-  private String message(BatchReport.Issue rawIssue) {
+  private static String message(BatchReport.Issue rawIssue) {
     return rawIssue.hasMsg() ? rawIssue.getMsg() : null;
   }
 
-  private void mapIssue(BatchReport.Issue rawIssue, @Nullable ServerIssue ref, IssueTrackingResult result) {
+  private static void mapIssue(BatchReport.Issue rawIssue, @Nullable ServerIssue ref, IssueTrackingResult result) {
     if (ref != null) {
       result.setMatch(rawIssue, ref);
     }
index e55ef46b03f4e8d8c84a3f49e194cfa68ccd2d8c..58e4213841239a2de7e0784584f59dfdaac335bb 100644 (file)
@@ -92,7 +92,7 @@ class IssueTrackingResult {
     unmatchedForRuleAndLine.put(checksumNotNull, i);
   }
 
-  private Integer lineNotNull(ServerIssue i) {
+  private static Integer lineNotNull(ServerIssue i) {
     Integer line = i.line();
     return line != null ? line : 0;
   }
index 01a218c2ae9207d24824a6d6bcf2c394db1c04b6..f202e5526138ffb7c4d5881ca33e5d65879443d0 100644 (file)
@@ -29,8 +29,6 @@ import java.util.Date;
 import java.util.List;
 import java.util.Set;
 import javax.annotation.CheckForNull;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.sonar.api.batch.BatchSide;
 import org.sonar.api.batch.fs.internal.DefaultInputFile;
 import org.sonar.api.batch.rule.ActiveRule;
@@ -57,8 +55,6 @@ import org.sonar.core.util.CloseableIterator;
 @BatchSide
 public class LocalIssueTracking {
 
-  private static final Logger LOG = LoggerFactory.getLogger(LocalIssueTracking.class);
-
   private final IssueCache issueCache;
   private final IssueTracking tracking;
   private final ServerLineHashesLoader lastLineHashes;
index 1212dd7ceaf7bf3c2d9b56bb55f119911a9277d0..e2d03e28ec92b6ab0a762d033e4ecc1b9d6b318c 100644 (file)
@@ -20,9 +20,7 @@
 package org.sonar.batch.issue.tracking;
 
 import com.google.common.base.Function;
-
 import javax.annotation.Nullable;
-
 import org.sonar.api.batch.BatchSide;
 import org.sonar.api.batch.InstantiationStrategy;
 import org.sonar.api.utils.log.Logger;
index e8d11a2d775c80bfe1caab42db1ad9abc7d2482e..d9e1687930d583c5035e00fd26008bcb7f17a687 100644 (file)
@@ -112,7 +112,7 @@ public class ComponentsPublisher implements ReportPublisherStep {
     }
   }
 
-  private String getVersion(ProjectDefinition def) {
+  private static String getVersion(ProjectDefinition def) {
     String version = def.getVersion();
     return StringUtils.isNotBlank(version) ? version : getVersion(def.getParent());
   }
@@ -130,7 +130,7 @@ public class ComponentsPublisher implements ReportPublisherStep {
     }
   }
 
-  private void writeProjectLink(BatchReport.Component.Builder componentBuilder, ProjectDefinition def, ComponentLink.Builder linkBuilder, String linkProp,
+  private static void writeProjectLink(BatchReport.Component.Builder componentBuilder, ProjectDefinition def, ComponentLink.Builder linkBuilder, String linkProp,
     ComponentLinkType linkType) {
     String link = def.properties().get(linkProp);
     if (StringUtils.isNotBlank(link)) {
@@ -142,19 +142,19 @@ public class ComponentsPublisher implements ReportPublisherStep {
   }
 
   @CheckForNull
-  private String getLanguageKey(Resource r) {
+  private static String getLanguageKey(Resource r) {
     Language language = r.getLanguage();
     return ResourceUtils.isFile(r) && language != null ? language.getKey() : null;
   }
 
   @CheckForNull
-  private String getName(Resource r) {
+  private static String getName(Resource r) {
     // Don't return name for directories and files since it can be guessed from the path
     return (ResourceUtils.isFile(r) || ResourceUtils.isDirectory(r)) ? null : r.getName();
   }
 
   @CheckForNull
-  private String getDescription(Resource r) {
+  private static String getDescription(Resource r) {
     // Only for projets and modules
     return ResourceUtils.isProject(r) ? r.getDescription() : null;
   }
index 7ab4959321d367762667ac4b84493237494c254d..2928ede2bbaeaefe2f77535f8429fc2002d2886a 100644 (file)
@@ -52,7 +52,7 @@ public class RulesProfileProvider extends ProviderAdapter {
     return singleton;
   }
 
-  private RulesProfile loadSingleLanguageProfile(ModuleQProfiles qProfiles, ActiveRules activeRules, String language) {
+  private static RulesProfile loadSingleLanguageProfile(ModuleQProfiles qProfiles, ActiveRules activeRules, String language) {
     QProfile qProfile = qProfiles.findByLanguage(language);
     if (qProfile != null) {
       return new RulesProfileWrapper(select(qProfile, activeRules));
@@ -60,7 +60,7 @@ public class RulesProfileProvider extends ProviderAdapter {
     return new RulesProfileWrapper(Lists.<RulesProfile>newArrayList());
   }
 
-  private RulesProfile loadProfiles(ModuleQProfiles qProfiles, ActiveRules activeRules) {
+  private static RulesProfile loadProfiles(ModuleQProfiles qProfiles, ActiveRules activeRules) {
     Collection<RulesProfile> dtos = Lists.newArrayList();
     for (QProfile qProfile : qProfiles.findAll()) {
       dtos.add(select(qProfile, activeRules));
@@ -68,7 +68,7 @@ public class RulesProfileProvider extends ProviderAdapter {
     return new RulesProfileWrapper(dtos);
   }
 
-  private RulesProfile select(QProfile qProfile, ActiveRules activeRules) {
+  private static RulesProfile select(QProfile qProfile, ActiveRules activeRules) {
     RulesProfile deprecatedProfile = new RulesProfile();
     // TODO deprecatedProfile.setVersion(qProfile.version());
     deprecatedProfile.setName(qProfile.getName());
index 10fa76df9be8f50eb9c82df8e5bdb84de0ea76cd..9729e8c51b73ea037ad3f5e66d04598ee4b809ee 100644 (file)
@@ -125,7 +125,7 @@ public class ProjectReactorBuilder {
     return new ProjectReactor(rootProject);
   }
 
-  private Map<String, Map<String, String>> extractPropertiesByModule(String currentModuleId, Map<String, String> parentProperties) {
+  private static Map<String, Map<String, String>> extractPropertiesByModule(String currentModuleId, Map<String, String> parentProperties) {
     Map<String, String> allProperties = new HashMap<>();
     allProperties.putAll(parentProperties);
     Map<String, String> currentModuleProperties = new HashMap<>();
@@ -202,7 +202,7 @@ public class ProjectReactorBuilder {
   }
 
   @CheckForNull
-  private File initModuleBuildDir(File moduleBaseDir, Map<String, String> moduleProperties) {
+  private static File initModuleBuildDir(File moduleBaseDir, Map<String, String> moduleProperties) {
     String buildDir = moduleProperties.get(PROPERTY_PROJECT_BUILDDIR);
     if (StringUtils.isBlank(buildDir)) {
       return null;
index af8b1a9b7b6ac7ff1dc628c753722f315bb65678..b53e457ab7cd864645e3386c9ac8fcef587dd798 100644 (file)
@@ -62,7 +62,7 @@ public class ProjectReactorValidator {
     }
   }
 
-  private void validateModule(ProjectDefinition moduleDef, List<String> validationMessages, @Nullable String branch, String rootProjectKey) {
+  private static void validateModule(ProjectDefinition moduleDef, List<String> validationMessages, @Nullable String branch, String rootProjectKey) {
     if (!ComponentKeys.isValidModuleKey(moduleDef.getKey())) {
       validationMessages.add(String.format("\"%s\" is not a valid project or module key. "
         + "Allowed characters are alphanumeric, '-', '_', '.' and ':', with at least one non-digit.", moduleDef.getKey()));
@@ -75,7 +75,7 @@ public class ProjectReactorValidator {
     }
   }
 
-  private void validateBranch(List<String> validationMessages, @Nullable String branch) {
+  private static void validateBranch(List<String> validationMessages, @Nullable String branch) {
     if (StringUtils.isNotEmpty(branch) && !ComponentKeys.isValidBranch(branch)) {
       validationMessages.add(String.format("\"%s\" is not a valid branch name. "
         + "Allowed characters are alphanumeric, '-', '_', '.' and '/'.", branch));
index 5809addf3f5eaa80beda6e353e03af34a0484012..24e26f5eb9470c43f7f8eeffb0cadb0c1e902884 100644 (file)
@@ -24,6 +24,14 @@ import com.google.common.base.Function;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Lists;
+import java.io.File;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.CoreProperties;
 import org.sonar.api.batch.fs.FilePredicate;
@@ -34,16 +42,6 @@ import org.sonar.api.scan.filesystem.FileQuery;
 import org.sonar.api.scan.filesystem.ModuleFileSystem;
 import org.sonar.api.utils.MessageException;
 
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.io.File;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
 /**
  * @since 3.5
  */
@@ -121,7 +119,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
     return testDirsOrFiles;
   }
 
-  private List<File> keepOnlyDirs(List<File> dirsOrFiles) {
+  private static List<File> keepOnlyDirs(List<File> dirsOrFiles) {
     List<File> result = new ArrayList<>();
     for (File f : dirsOrFiles) {
       if (f.isDirectory()) {
@@ -173,7 +171,7 @@ public class DefaultModuleFileSystem extends DefaultFileSystem implements Module
     throw modificationNotPermitted();
   }
 
-  private UnsupportedOperationException modificationNotPermitted() {
+  private static UnsupportedOperationException modificationNotPermitted() {
     return new UnsupportedOperationException("Modifications of the file system are not permitted");
   }
 
index c68995dfa3fb7d1f1d783114e17780d6aac5e1be..4baa10412bb770f2a2e14da3a6988cffbc100ae2 100644 (file)
 package org.sonar.batch.scan.filesystem;
 
 import com.google.common.annotations.VisibleForTesting;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.sonar.api.batch.BatchSide;
-import org.sonar.api.scan.filesystem.PathResolver;
-
 import java.io.File;
 import java.nio.charset.Charset;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.batch.BatchSide;
+import org.sonar.api.scan.filesystem.PathResolver;
 
 @BatchSide
 public class FileSystemLogger {
@@ -63,7 +62,7 @@ public class FileSystemLogger {
     }
   }
 
-  private void logPaths(Logger logger, String label, File baseDir, List<File> paths) {
+  private static void logPaths(Logger logger, String label, File baseDir, List<File> paths) {
     if (!paths.isEmpty()) {
       PathResolver resolver = new PathResolver();
       StringBuilder sb = new StringBuilder(label);
index b9c8f06511b86bf152a1da30013f72e04c3b28a8..5d740d3592e4bd72f2559bf6a41623544f34e094 100644 (file)
@@ -58,7 +58,7 @@ class MeasureValueCoder implements ValueCoder {
     value.putString(persistenceMode != null ? persistenceMode.name() : null);
   }
 
-  private void putUTFOrNull(Value value, @Nullable String utfOrNull) {
+  private static void putUTFOrNull(Value value, @Nullable String utfOrNull) {
     if (utfOrNull != null) {
       value.putUTF(utfOrNull);
     } else {
index 2634fdd9af978d93ce4cef87166a8dc994acabdb..0627d986451e78401ca4812861681a4deb96b3c4 100644 (file)
@@ -25,12 +25,12 @@ import org.sonar.api.Properties;
 import org.sonar.api.Property;
 import org.sonar.api.PropertyType;
 import org.sonar.api.config.Settings;
-import org.sonar.core.issue.DefaultIssue;
 import org.sonar.api.rule.Severity;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 import org.sonar.batch.issue.IssueCache;
 import org.sonar.batch.scan.filesystem.InputPathCache;
+import org.sonar.core.issue.DefaultIssue;
 
 @Properties({
   @Property(key = ConsoleReport.CONSOLE_REPORT_ENABLED_KEY, name = "Enable console report", description = "Set this to true to generate a report in console output",
@@ -135,7 +135,7 @@ public class ConsoleReport implements Reporter {
     }
   }
 
-  private void printNewIssues(StringBuilder sb, int issueCount, String severity, String severityLabel) {
+  private static void printNewIssues(StringBuilder sb, int issueCount, String severity, String severityLabel) {
     if (issueCount > 0) {
       sb.append(StringUtils.leftPad("+" + issueCount, LEFT_PAD)).append(" ").append(severityLabel).append("\n");
     }
index 37400982c112d20c00fd81d1c37bef5ab5eeb914..ec89540927afd00c1558aa545149360ce1bb59d4 100644 (file)
  */
 package org.sonar.batch.scan.report;
 
-import org.sonar.api.batch.rule.Rule;
-
-import org.sonar.api.batch.rule.Rules;
+import javax.annotation.CheckForNull;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.batch.BatchSide;
+import org.sonar.api.batch.rule.Rule;
+import org.sonar.api.batch.rule.Rules;
 import org.sonar.api.issue.Issue;
-import org.sonar.core.issue.DefaultIssue;
 import org.sonar.api.resources.Project;
 import org.sonar.api.rules.RulePriority;
 import org.sonar.batch.DefaultProjectTree;
@@ -34,8 +33,7 @@ import org.sonar.batch.index.BatchComponent;
 import org.sonar.batch.index.BatchComponentCache;
 import org.sonar.batch.issue.IssueCache;
 import org.sonar.batch.scan.filesystem.InputPathCache;
-
-import javax.annotation.CheckForNull;
+import org.sonar.core.issue.DefaultIssue;
 
 @BatchSide
 public class IssuesReportBuilder {
@@ -84,7 +82,7 @@ public class IssuesReportBuilder {
     }
   }
 
-  private boolean validate(Issue issue, Rule rule, BatchComponent resource) {
+  private static boolean validate(Issue issue, Rule rule, BatchComponent resource) {
     if (rule == null) {
       LOG.warn("Unknow rule for issue {}", issue);
       return false;
index e4a9c06f8b894d5e6b3ae313062ea58bbc79cf83..e5fb62516afbf95f775b8fc087dd94bbe5e52f07 100644 (file)
@@ -38,27 +38,27 @@ public class RuleReportComparator implements Comparator<RuleReport>, Serializabl
     }
   }
 
-  private int compareByRuleSeverityAndName(RuleReport o1, RuleReport o2) {
+  private static int compareByRuleSeverityAndName(RuleReport o1, RuleReport o2) {
     return o1.getReportRuleKey().compareTo(o2.getReportRuleKey());
   }
 
-  private boolean sameNewIssueCount(RuleReport o1, RuleReport o2) {
+  private static boolean sameNewIssueCount(RuleReport o1, RuleReport o2) {
     return o2.getTotal().getNewIssuesCount() == o1.getTotal().getNewIssuesCount();
   }
 
-  private boolean sameSeverity(RuleReport o1, RuleReport o2) {
+  private static boolean sameSeverity(RuleReport o1, RuleReport o2) {
     return o1.getSeverity().equals(o2.getSeverity());
   }
 
-  private int compareNewIssueCount(RuleReport o1, RuleReport o2) {
+  private static int compareNewIssueCount(RuleReport o1, RuleReport o2) {
     return o2.getTotal().getNewIssuesCount() - o1.getTotal().getNewIssuesCount();
   }
 
-  private boolean bothHaveNewIssues(RuleReport o1, RuleReport o2) {
+  private static boolean bothHaveNewIssues(RuleReport o1, RuleReport o2) {
     return o1.getTotal().getNewIssuesCount() > 0 && o2.getTotal().getNewIssuesCount() > 0;
   }
 
-  private boolean bothHaveNoNewIssue(RuleReport o1, RuleReport o2) {
+  private static boolean bothHaveNoNewIssue(RuleReport o1, RuleReport o2) {
     return o1.getTotal().getNewIssuesCount() == 0 && o2.getTotal().getNewIssuesCount() == 0;
   }
 }
index dd7d4631138bb9100d3131978d2fb298c043e7d4..38371c740b81e569dd53b9c4705c2085ef5f4dd5 100644 (file)
@@ -31,17 +31,14 @@ import org.sonar.api.batch.BatchSide;
 import org.sonar.api.batch.fs.FileSystem;
 import org.sonar.api.batch.fs.InputFile;
 import org.sonar.batch.index.BatchComponent;
-import org.sonar.batch.scan.filesystem.InputPathCache;
 
 @BatchSide
 public class SourceProvider {
 
   private static final Logger LOG = LoggerFactory.getLogger(SourceProvider.class);
-  private final InputPathCache inputPathCache;
   private final FileSystem fs;
 
-  public SourceProvider(InputPathCache inputPathCache, FileSystem fs) {
-    this.inputPathCache = inputPathCache;
+  public SourceProvider(FileSystem fs) {
     this.fs = fs;
   }
 
index 33ec11e25f577e11f3d494466aca36fb80612f81..f7ccc0b3e5184524117759effcfcd5d9bbf964bd 100644 (file)
 package org.sonar.batch.scm;
 
 import com.google.common.base.Preconditions;
+import java.text.Normalizer;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Pattern;
+import javax.annotation.Nullable;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -33,13 +43,6 @@ import org.sonar.batch.protocol.output.BatchReport.Changesets.Builder;
 import org.sonar.batch.protocol.output.BatchReportWriter;
 import org.sonar.batch.util.ProgressReport;
 
-import javax.annotation.Nullable;
-
-import java.text.Normalizer;
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-import java.util.regex.Pattern;
-
 class DefaultBlameOutput implements BlameOutput {
 
   private static final Logger LOG = LoggerFactory.getLogger(DefaultBlameOutput.class);
@@ -99,7 +102,7 @@ class DefaultBlameOutput implements BlameOutput {
     progressReport.message(count + "/" + total + " files analyzed, last one was " + file.absolutePath());
   }
 
-  private void addChangeset(Builder scmBuilder, BlameLine line) {
+  private static void addChangeset(Builder scmBuilder, BlameLine line) {
     BatchReport.Changesets.Changeset.Builder changesetBuilder = BatchReport.Changesets.Changeset.newBuilder();
     if (StringUtils.isNotBlank(line.revision())) {
       changesetBuilder.setRevision(line.revision());
@@ -114,7 +117,7 @@ class DefaultBlameOutput implements BlameOutput {
     scmBuilder.addChangeset(changesetBuilder.build());
   }
 
-  private String normalizeString(@Nullable String inputString) {
+  private static String normalizeString(@Nullable String inputString) {
     if (inputString == null) {
       return "";
     }
@@ -123,12 +126,12 @@ class DefaultBlameOutput implements BlameOutput {
     return removeNonAsciiCharacters(stringWithoutAccents);
   }
 
-  private String removeAccents(String inputString) {
+  private static String removeAccents(String inputString) {
     String unicodeDecomposedString = Normalizer.normalize(inputString, Normalizer.Form.NFD);
     return ACCENT_CODES.matcher(unicodeDecomposedString).replaceAll("");
   }
 
-  private String removeNonAsciiCharacters(String inputString) {
+  private static String removeNonAsciiCharacters(String inputString) {
     return NON_ASCII_CHARS.matcher(inputString).replaceAll("_");
   }
 
index a74ad87c3e1ec23ac6dd66d8f212f5de0a45d213..a57fb5556c357e782e417df28456eeb3cb6f9892 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.batch.scm;
 
+import java.util.LinkedList;
+import java.util.List;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.api.CoreProperties;
@@ -35,9 +37,6 @@ import org.sonar.batch.protocol.input.ProjectRepositories;
 import org.sonar.batch.report.ReportPublisher;
 import org.sonar.batch.scan.filesystem.InputPathCache;
 
-import java.util.LinkedList;
-import java.util.List;
-
 public final class ScmSensor implements Sensor {
 
   private static final Logger LOG = LoggerFactory.getLogger(ScmSensor.class);
@@ -105,7 +104,7 @@ public final class ScmSensor implements Sensor {
     return filesToBlame;
   }
 
-  private void addIfNotEmpty(List<InputFile> filesToBlame, InputFile f) {
+  private static void addIfNotEmpty(List<InputFile> filesToBlame, InputFile f) {
     if (!f.isEmpty()) {
       filesToBlame.add(f);
     }
index 89343b7274a7aab884ba237f4b8da98a5e283ddd..4439043e370b75ef5288ee68b89e188690ef7f9a 100644 (file)
@@ -124,7 +124,7 @@ public class CoverageExclusions {
     log("Excluded sources for coverage: ", resourcePatterns);
   }
 
-  private void log(String title, Collection<WildcardPattern> patterns) {
+  private static void log(String title, Collection<WildcardPattern> patterns) {
     if (!patterns.isEmpty()) {
       LOG.info(title);
       for (WildcardPattern pattern : patterns) {
index 6bfe739b19617091b3ae0b22724d54914782e2a5..8dc53a3cdfb3af2f9cd55820b89b65bfe1a39ddc 100644 (file)
@@ -79,7 +79,7 @@ public class DefaultTestable implements MutableTestable {
     throw unsupported();
   }
 
-  private UnsupportedOperationException unsupported() {
+  private static UnsupportedOperationException unsupported() {
     return new UnsupportedOperationException("No more available since SQ 5.2");
   }
 
index f16e8d3c2e226fa09b8ca2847dc592a7b021f2b5..9f3fcb161702a666ebd83ebba5fa51f78db175b7 100644 (file)
@@ -342,7 +342,7 @@ public class DefaultIssue implements Issue, Trackable {
 
   public DefaultIssue setCreationDate(Date d) {
     // d is not marked as Nullable but we still allow null parameter for unit testing.
-    this.creationDate = (d != null ? DateUtils.truncate(d, Calendar.SECOND) : null);
+    this.creationDate = d != null ? DateUtils.truncate(d, Calendar.SECOND) : null;
     return this;
   }
 
@@ -353,7 +353,7 @@ public class DefaultIssue implements Issue, Trackable {
   }
 
   public DefaultIssue setUpdateDate(@Nullable Date d) {
-    this.updateDate = (d != null ? DateUtils.truncate(d, Calendar.SECOND) : null);
+    this.updateDate = d != null ? DateUtils.truncate(d, Calendar.SECOND) : null;
     return this;
   }
 
@@ -364,7 +364,7 @@ public class DefaultIssue implements Issue, Trackable {
   }
 
   public DefaultIssue setCloseDate(@Nullable Date d) {
-    this.closeDate = (d != null ? DateUtils.truncate(d, Calendar.SECOND) : null);
+    this.closeDate = d != null ? DateUtils.truncate(d, Calendar.SECOND) : null;
     return this;
   }
 
index 90031326979ac8a591969777c1db8a23f6b1e9ef..1d743ebd126315da4bc497cc593f6adc354c6681 100644 (file)
@@ -28,7 +28,7 @@ import java.util.List;
 import org.apache.commons.dbutils.DbUtils;
 import org.sonar.db.Database;
 
-class SelectImpl extends BaseSqlStatement<Select> implements Select {
+class SelectImpl extends BaseSqlStatement<Select>implements Select {
 
   private SelectImpl(PreparedStatement pstmt) {
     super(pstmt);
@@ -85,7 +85,7 @@ class SelectImpl extends BaseSqlStatement<Select> implements Select {
     }
   }
 
-  private IllegalStateException newExceptionWithRowDetails(Select.Row row, Exception e) {
+  private static IllegalStateException newExceptionWithRowDetails(Select.Row row, Exception e) {
     return new IllegalStateException("Error during processing of row: [" + row + "]", e);
   }
 
index 2018f7ac0ed7a0552f29270912a409b5f2831ee0..32737cc3a0eb2ea464e93938cb1ee1ce9e17cd7e 100644 (file)
@@ -40,6 +40,18 @@ import org.sonar.api.rule.RuleKey;
 
 public class DefaultIssue extends DefaultStorable implements Issue, NewIssue {
 
+  private static final class ToExecutionFlow implements Function<List<IssueLocation>, ExecutionFlow> {
+    @Override
+    public ExecutionFlow apply(final List<IssueLocation> input) {
+      return new ExecutionFlow() {
+        @Override
+        public List<IssueLocation> locations() {
+          return ImmutableList.copyOf(input);
+        }
+      };
+    }
+  }
+
   private RuleKey ruleKey;
   private Double effortToFix;
   private Severity overriddenSeverity;
@@ -141,17 +153,7 @@ public class DefaultIssue extends DefaultStorable implements Issue, NewIssue {
 
   @Override
   public List<ExecutionFlow> executionFlows() {
-    return Lists.transform(this.executionFlows, new Function<List<IssueLocation>, ExecutionFlow>() {
-      @Override
-      public ExecutionFlow apply(final List<IssueLocation> input) {
-        return new ExecutionFlow() {
-          @Override
-          public List<IssueLocation> locations() {
-            return ImmutableList.copyOf(input);
-          }
-        };
-      }
-    });
+    return Lists.transform(this.executionFlows, new ToExecutionFlow());
   }
 
   @Override