aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2014-09-01 17:27:45 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2014-09-01 17:28:09 +0200
commita9bd7ecdd2b0f138275c1bb2954ab6ee9b804844 (patch)
treefb1759dc69571ef8050ced531609c69045578b25 /plugins
parented80a6430099a0dfd3bc7f016a8392bf22896b74 (diff)
downloadsonarqube-a9bd7ecdd2b0f138275c1bb2954ab6ee9b804844.tar.gz
sonarqube-a9bd7ecdd2b0f138275c1bb2954ab6ee9b804844.zip
Fix some quality flaws
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DefaultCpdEngine.java35
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/JavaCpdEngine.java30
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/IndexFactory.java2
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooConstants.java36
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/MeasureSensor.java9
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java40
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java39
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java5
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssueOnDirPerFileSensor.java5
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java5
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java6
11 files changed, 95 insertions, 117 deletions
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DefaultCpdEngine.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DefaultCpdEngine.java
index 887c886ac1e..925ecb87638 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DefaultCpdEngine.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/DefaultCpdEngine.java
@@ -110,22 +110,7 @@ public class DefaultCpdEngine extends CpdEngine {
// Create index
SonarDuplicationsIndex index = indexFactory.create(project, languageKey);
-
- TokenizerBridge bridge = null;
- if (mapping != null) {
- bridge = new TokenizerBridge(mapping.getTokenizer(), fs.encoding().name(), getBlockSize(languageKey));
- }
- for (InputFile inputFile : sourceFiles) {
- LOG.debug("Populating index from {}", inputFile);
- String resourceEffectiveKey = ((DeprecatedDefaultInputFile) inputFile).key();
- FileBlocks fileBlocks = duplicationCache.byComponent(resourceEffectiveKey);
- if (fileBlocks != null) {
- index.insert(inputFile, fileBlocks.blocks());
- } else if (bridge != null) {
- List<Block> blocks2 = bridge.chunk(resourceEffectiveKey, inputFile.file());
- index.insert(inputFile, blocks2);
- }
- }
+ populateIndex(languageKey, sourceFiles, mapping, index);
// Detect
Predicate<CloneGroup> minimumTokensPredicate = DuplicationPredicates.numberOfUnitsNotLessThan(getMinimumTokens(languageKey));
@@ -157,6 +142,24 @@ public class DefaultCpdEngine extends CpdEngine {
}
}
+ private void populateIndex(String languageKey, List<InputFile> sourceFiles, CpdMapping mapping, SonarDuplicationsIndex index) {
+ TokenizerBridge bridge = null;
+ if (mapping != null) {
+ bridge = new TokenizerBridge(mapping.getTokenizer(), fs.encoding().name(), getBlockSize(languageKey));
+ }
+ for (InputFile inputFile : sourceFiles) {
+ LOG.debug("Populating index from {}", inputFile);
+ String resourceEffectiveKey = ((DeprecatedDefaultInputFile) inputFile).key();
+ FileBlocks fileBlocks = duplicationCache.byComponent(resourceEffectiveKey);
+ if (fileBlocks != null) {
+ index.insert(inputFile, fileBlocks.blocks());
+ } else if (bridge != null) {
+ List<Block> blocks2 = bridge.chunk(resourceEffectiveKey, inputFile.file());
+ index.insert(inputFile, blocks2);
+ }
+ }
+ }
+
@VisibleForTesting
int getBlockSize(String languageKey) {
int blockSize = settings.getInt("sonar.cpd." + languageKey + ".minimumLines");
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/JavaCpdEngine.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/JavaCpdEngine.java
index 43585d4db4f..a5770634444 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/JavaCpdEngine.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/JavaCpdEngine.java
@@ -198,20 +198,8 @@ public class JavaCpdEngine extends CpdEngine {
if (duplications == null || Iterables.isEmpty(duplications)) {
return;
}
- // Calculate number of lines and blocks
Set<Integer> duplicatedLines = new HashSet<Integer>();
- int duplicatedBlocks = 0;
- for (CloneGroup clone : duplications) {
- ClonePart origin = clone.getOriginPart();
- for (ClonePart part : clone.getCloneParts()) {
- if (part.getResourceId().equals(origin.getResourceId())) {
- duplicatedBlocks++;
- for (int duplicatedLine = part.getStartLine(); duplicatedLine < part.getStartLine() + part.getLines(); duplicatedLine++) {
- duplicatedLines.add(duplicatedLine);
- }
- }
- }
- }
+ int duplicatedBlocks = computeBlockAndLineCount(duplications, duplicatedLines);
FileLinesContext linesContext = contextFactory.createFor(inputFile);
for (int i = 1; i <= inputFile.lines(); i++) {
linesContext.setIntValue(CoreMetrics.DUPLICATION_LINES_DATA_KEY, i, duplicatedLines.contains(i) ? 1 : 0);
@@ -246,4 +234,20 @@ public class JavaCpdEngine extends CpdEngine {
context.saveDuplications(inputFile, builder.build());
}
+ private static int computeBlockAndLineCount(Iterable<CloneGroup> duplications, Set<Integer> duplicatedLines) {
+ int duplicatedBlocks = 0;
+ for (CloneGroup clone : duplications) {
+ ClonePart origin = clone.getOriginPart();
+ for (ClonePart part : clone.getCloneParts()) {
+ if (part.getResourceId().equals(origin.getResourceId())) {
+ duplicatedBlocks++;
+ for (int duplicatedLine = part.getStartLine(); duplicatedLine < part.getStartLine() + part.getLines(); duplicatedLine++) {
+ duplicatedLines.add(duplicatedLine);
+ }
+ }
+ }
+ }
+ return duplicatedBlocks;
+ }
+
}
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/IndexFactory.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/IndexFactory.java
index 6d5a7f1201d..9830f4b1dd0 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/IndexFactory.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/index/IndexFactory.java
@@ -64,7 +64,7 @@ public class IndexFactory implements BatchComponent {
}
@VisibleForTesting
- boolean verifyCrossProject(Project project, Logger logger) {
+ boolean verifyCrossProject(@Nullable Project project, Logger logger) {
boolean crossProject = false;
if (settings.getBoolean(CoreProperties.CPD_CROSS_PROJECT)) {
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooConstants.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooConstants.java
deleted file mode 100644
index 62f7d2ba782..00000000000
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooConstants.java
+++ /dev/null
@@ -1,36 +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.xoo;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public interface XooConstants {
-
- String PLUGIN_KEY = "xoo";
- String PLUGIN_NAME = "Xoo";
-
- String REPOSITORY_KEY = PLUGIN_KEY;
- String REPOSITORY_NAME = PLUGIN_NAME;
-
- String[] FILE_SUFFIXES = {"xoo"};
-
- Logger LOG = LoggerFactory.getLogger("xoo");
-}
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/MeasureSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/MeasureSensor.java
index bc796808f19..4ce85626d15 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/MeasureSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/MeasureSensor.java
@@ -21,6 +21,8 @@ package org.sonar.xoo.lang;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.measure.MetricFinder;
import org.sonar.api.batch.sensor.Sensor;
@@ -30,7 +32,6 @@ import org.sonar.api.batch.sensor.measure.Measure;
import org.sonar.api.batch.sensor.measure.MeasureBuilder;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.xoo.Xoo;
-import org.sonar.xoo.XooConstants;
import java.io.File;
import java.io.IOException;
@@ -42,6 +43,8 @@ import java.util.List;
*/
public class MeasureSensor implements Sensor {
+ private static final Logger LOG = LoggerFactory.getLogger(MeasureSensor.class);
+
private static final String MEASURES_EXTENSION = ".measures";
private MetricFinder metricFinder;
@@ -54,7 +57,7 @@ public class MeasureSensor implements Sensor {
File ioFile = inputFile.file();
File measureFile = new File(ioFile.getParentFile(), ioFile.getName() + MEASURES_EXTENSION);
if (measureFile.exists()) {
- XooConstants.LOG.debug("Processing " + measureFile.getAbsolutePath());
+ LOG.debug("Processing " + measureFile.getAbsolutePath());
try {
List<String> lines = FileUtils.readLines(measureFile, context.fileSystem().encoding().name());
int lineNumber = 0;
@@ -81,7 +84,7 @@ public class MeasureSensor implements Sensor {
}
}
- private Measure<?> createMeasure(SensorContext context, InputFile xooFile, String metricKey, String value) {
+ private Measure createMeasure(SensorContext context, InputFile xooFile, String metricKey, String value) {
org.sonar.api.batch.measure.Metric<Serializable> metric = metricFinder.findByKey(metricKey);
if (metric == null) {
throw new IllegalStateException("Unknow metric with key: " + metricKey);
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java
index 628ce6ece70..c8232484a51 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SymbolReferencesSensor.java
@@ -22,6 +22,8 @@ package org.sonar.xoo.lang;
import com.google.common.base.Splitter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
@@ -30,7 +32,6 @@ import org.sonar.api.batch.sensor.symbol.Symbol;
import org.sonar.api.batch.sensor.symbol.SymbolTableBuilder;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.xoo.Xoo;
-import org.sonar.xoo.XooConstants;
import java.io.File;
import java.io.IOException;
@@ -42,41 +43,44 @@ import java.util.List;
*/
public class SymbolReferencesSensor implements Sensor {
+ private static final Logger LOG = LoggerFactory.getLogger(SymbolReferencesSensor.class);
+
private static final String SYMBOL_EXTENSION = ".symbol";
private void processFileSymbol(InputFile inputFile, SensorContext context) {
File ioFile = inputFile.file();
File symbolFile = new File(ioFile.getParentFile(), ioFile.getName() + SYMBOL_EXTENSION);
if (symbolFile.exists()) {
- XooConstants.LOG.debug("Processing " + symbolFile.getAbsolutePath());
+ LOG.debug("Processing " + symbolFile.getAbsolutePath());
try {
List<String> lines = FileUtils.readLines(symbolFile, context.fileSystem().encoding().name());
int lineNumber = 0;
SymbolTableBuilder symbolTableBuilder = context.symbolTableBuilder(inputFile);
for (String line : lines) {
lineNumber++;
- if (StringUtils.isBlank(line)) {
- continue;
- }
- if (line.startsWith("#")) {
+ if (StringUtils.isBlank(line) || line.startsWith("#")) {
continue;
}
- try {
- Iterator<String> split = Splitter.on(",").split(line).iterator();
- int startOffset = Integer.parseInt(split.next());
- int endOffset = Integer.parseInt(split.next());
- Symbol s = symbolTableBuilder.newSymbol(startOffset, endOffset);
- while (split.hasNext()) {
- symbolTableBuilder.newReference(s, Integer.parseInt(split.next()));
- }
- } catch (Exception e) {
- throw new IllegalStateException("Error processing line " + lineNumber + " of file " + symbolFile.getAbsolutePath(), e);
- }
+ processLine(symbolFile, lineNumber, symbolTableBuilder, line);
}
symbolTableBuilder.done();
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+
+ private void processLine(File symbolFile, int lineNumber, SymbolTableBuilder symbolTableBuilder, String line) {
+ try {
+ Iterator<String> split = Splitter.on(",").split(line).iterator();
+ int startOffset = Integer.parseInt(split.next());
+ int endOffset = Integer.parseInt(split.next());
+ Symbol s = symbolTableBuilder.newSymbol(startOffset, endOffset);
+ while (split.hasNext()) {
+ symbolTableBuilder.newReference(s, Integer.parseInt(split.next()));
}
+ } catch (Exception e) {
+ throw new IllegalStateException("Error processing line " + lineNumber + " of file " + symbolFile.getAbsolutePath(), e);
}
}
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java
index ca2f6b5e0ac..c9c9b886406 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/SyntaxHighlightingSensor.java
@@ -19,19 +19,19 @@
*/
package org.sonar.xoo.lang;
-import org.sonar.api.batch.sensor.highlighting.TypeOfText;
-
import com.google.common.base.Splitter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.batch.sensor.highlighting.HighlightingBuilder;
+import org.sonar.api.batch.sensor.highlighting.TypeOfText;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.xoo.Xoo;
-import org.sonar.xoo.XooConstants;
import java.io.File;
import java.io.IOException;
@@ -43,42 +43,45 @@ import java.util.List;
*/
public class SyntaxHighlightingSensor implements Sensor {
+ private static final Logger LOG = LoggerFactory.getLogger(SyntaxHighlightingSensor.class);
+
private static final String HIGHLIGHTING_EXTENSION = ".highlighting";
private void processFileHighlighting(InputFile inputFile, SensorContext context) {
File ioFile = inputFile.file();
File highlightingFile = new File(ioFile.getParentFile(), ioFile.getName() + HIGHLIGHTING_EXTENSION);
if (highlightingFile.exists()) {
- XooConstants.LOG.debug("Processing " + highlightingFile.getAbsolutePath());
+ LOG.debug("Processing " + highlightingFile.getAbsolutePath());
try {
List<String> lines = FileUtils.readLines(highlightingFile, context.fileSystem().encoding().name());
int lineNumber = 0;
HighlightingBuilder highlightingBuilder = context.highlightingBuilder(inputFile);
for (String line : lines) {
lineNumber++;
- if (StringUtils.isBlank(line)) {
- continue;
- }
- if (line.startsWith("#")) {
+ if (StringUtils.isBlank(line) || line.startsWith("#")) {
continue;
}
- try {
- Iterator<String> split = Splitter.on(":").split(line).iterator();
- int startOffset = Integer.parseInt(split.next());
- int endOffset = Integer.parseInt(split.next());
- TypeOfText type = TypeOfText.forCssClass(split.next());
- highlightingBuilder.highlight(startOffset, endOffset, type);
- } catch (Exception e) {
- throw new IllegalStateException("Error processing line " + lineNumber + " of file " + highlightingFile.getAbsolutePath(), e);
- }
+ processLine(highlightingFile, lineNumber, highlightingBuilder, line);
}
highlightingBuilder.done();
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
}
+ private void processLine(File highlightingFile, int lineNumber, HighlightingBuilder highlightingBuilder, String line) {
+ try {
+ Iterator<String> split = Splitter.on(":").split(line).iterator();
+ int startOffset = Integer.parseInt(split.next());
+ int endOffset = Integer.parseInt(split.next());
+ TypeOfText type = TypeOfText.forCssClass(split.next());
+ highlightingBuilder.highlight(startOffset, endOffset, type);
+ } catch (Exception e) {
+ throw new IllegalStateException("Error processing line " + lineNumber + " of file " + highlightingFile.getAbsolutePath(), e);
+ }
+ }
+
@Override
public void describe(SensorDescriptor descriptor) {
descriptor
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java
index c3e7d2641e6..041bdd94efd 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/CreateIssueByInternalKeySensor.java
@@ -25,7 +25,6 @@ import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.xoo.Xoo;
-import org.sonar.xoo.XooConstants;
public class CreateIssueByInternalKeySensor implements Sensor {
@@ -36,7 +35,7 @@ public class CreateIssueByInternalKeySensor implements Sensor {
descriptor
.name("CreateIssueByInternalKeySensor")
.workOnLanguages(Xoo.KEY)
- .createIssuesForRuleRepositories(XooConstants.REPOSITORY_KEY)
+ .createIssuesForRuleRepositories(XooRulesDefinition.XOO_REPOSITORY)
.workOnFileTypes(InputFile.Type.MAIN, InputFile.Type.TEST);
}
@@ -48,7 +47,7 @@ public class CreateIssueByInternalKeySensor implements Sensor {
}
private void createIssues(InputFile file, SensorContext context) {
- ActiveRule rule = context.activeRules().findByInternalKey(XooConstants.REPOSITORY_KEY,
+ ActiveRule rule = context.activeRules().findByInternalKey(XooRulesDefinition.XOO_REPOSITORY,
context.settings().getString(INTERNAL_KEY_PROPERTY));
if (rule != null) {
context.addIssue(context.issueBuilder()
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssueOnDirPerFileSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssueOnDirPerFileSensor.java
index c2478830975..6763d0308c8 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssueOnDirPerFileSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssueOnDirPerFileSensor.java
@@ -26,7 +26,6 @@ import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.rule.RuleKey;
import org.sonar.xoo.Xoo;
-import org.sonar.xoo.XooConstants;
public class OneIssueOnDirPerFileSensor implements Sensor {
@@ -37,7 +36,7 @@ public class OneIssueOnDirPerFileSensor implements Sensor {
descriptor
.name("One Issue On Dir Per File")
.workOnLanguages(Xoo.KEY)
- .createIssuesForRuleRepositories(XooConstants.REPOSITORY_KEY)
+ .createIssuesForRuleRepositories(XooRulesDefinition.XOO_REPOSITORY)
.workOnFileTypes(InputFile.Type.MAIN, InputFile.Type.TEST);
}
@@ -49,7 +48,7 @@ public class OneIssueOnDirPerFileSensor implements Sensor {
}
private void createIssues(InputFile file, SensorContext context) {
- RuleKey ruleKey = RuleKey.of(XooConstants.REPOSITORY_KEY, RULE_KEY);
+ RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY);
InputDir inputDir = context.fileSystem().inputDir(file.file().getParentFile());
if (inputDir != null) {
context.addIssue(context.issueBuilder()
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java
index bc0697b64b4..e65efa43718 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/OneIssuePerLineSensor.java
@@ -29,7 +29,6 @@ import org.sonar.api.batch.sensor.measure.Measure;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.rule.RuleKey;
import org.sonar.xoo.Xoo;
-import org.sonar.xoo.XooConstants;
public class OneIssuePerLineSensor implements Sensor {
@@ -43,7 +42,7 @@ public class OneIssuePerLineSensor implements Sensor {
.name("One Issue Per Line")
.dependsOn(CoreMetrics.LINES)
.workOnLanguages(Xoo.KEY)
- .createIssuesForRuleRepositories(XooConstants.REPOSITORY_KEY)
+ .createIssuesForRuleRepositories(XooRulesDefinition.XOO_REPOSITORY)
.workOnFileTypes(InputFile.Type.MAIN, InputFile.Type.TEST);
}
@@ -55,7 +54,7 @@ public class OneIssuePerLineSensor implements Sensor {
}
private void createIssues(InputFile file, SensorContext context) {
- RuleKey ruleKey = RuleKey.of(XooConstants.REPOSITORY_KEY, RULE_KEY);
+ RuleKey ruleKey = RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY);
Measure<Integer> linesMeasure = context.getMeasure(file, CoreMetrics.LINES);
if (linesMeasure == null) {
LoggerFactory.getLogger(getClass()).warn("Missing measure " + CoreMetrics.LINES_KEY + " on " + file);
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java
index c05fe0e0976..0f37cefcb42 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/rule/XooRulesDefinition.java
@@ -42,13 +42,13 @@ public class XooRulesDefinition implements RulesDefinition {
.setName("No empty line")
.setMarkdownDescription("Generate an issue on *empty* lines of Xoo source files")
- // optional tags
+ // optional tags
.setTags("style", "security")
- // optional status. Default value is READY.
+ // optional status. Default value is READY.
.setStatus(RuleStatus.BETA)
- // default severity when the rule is activated on a Quality profile. Default value is MAJOR.
+ // default severity when the rule is activated on a Quality profile. Default value is MAJOR.
.setSeverity(Severity.MINOR);
// debt-related information