Skip to content

Commit d42712a

Browse files
gaurabdgromani
authored andcommitted
Issue #335: Bad name of modules in metadata for JavaNCSS and NPathComplexity
1 parent 31c8625 commit d42712a

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

src/main/java/org/sonar/plugins/checkstyle/metadata/CheckstyleMetadata.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@
3939
import com.fasterxml.jackson.databind.ObjectMapper;
4040
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
4141
import com.google.common.collect.ImmutableList;
42+
import com.google.common.collect.ImmutableMap;
4243
import com.puppycrawl.tools.checkstyle.meta.ModuleDetails;
4344
import com.puppycrawl.tools.checkstyle.meta.ModulePropertyDetails;
4445
import com.puppycrawl.tools.checkstyle.meta.ModuleType;
4546
import com.puppycrawl.tools.checkstyle.meta.XmlMetaReader;
4647

4748
public class CheckstyleMetadata {
48-
private static final String OPTION_STRING = "Option";
49-
private static final String COMMA_STRING = ",";
5049
private static final List<String> NO_SQALE = ImmutableList.of(
5150
"com.puppycrawl.tools.checkstyle.checks.TranslationCheck",
5251
"com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck",
@@ -60,7 +59,16 @@ public class CheckstyleMetadata {
6059
"com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck",
6160
"com.puppycrawl.tools.checkstyle.checks.SuppressWarningsHolder"
6261
);
62+
63+
private static final Map<String, String> MODULE_NAME_EXCEPTIONS = ImmutableMap.of(
64+
"JavaNCSS", "Java NCSS",
65+
"NPathComplexity", "NPath Complexity"
66+
);
67+
68+
private static final String OPTION_STRING = "Option";
69+
private static final String COMMA_STRING = ",";
6370
private static final int PARAM_TYPE_DB_COLUMN_TYPE_SIZE_LIMIT = 512;
71+
6472
private final RulesDefinition.NewRepository repository;
6573
private final Map<String, ModuleDetails> metadataRepo;
6674

@@ -314,10 +322,16 @@ private static String getRuleTag(String checkPackage,
314322
public static String getFullCheckName(String checkName) {
315323
final int capacity = 1024;
316324
final StringBuilder result = new StringBuilder(capacity);
317-
for (int i = 0; i < checkName.length(); i++) {
318-
result.append(checkName.charAt(i));
319-
if (i + 1 < checkName.length() && Character.isUpperCase(checkName.charAt(i + 1))) {
320-
result.append(' ');
325+
326+
if (MODULE_NAME_EXCEPTIONS.containsKey(checkName)) {
327+
result.append(MODULE_NAME_EXCEPTIONS.get(checkName));
328+
}
329+
else {
330+
for (int i = 0; i < checkName.length(); i++) {
331+
result.append(checkName.charAt(i));
332+
if (i + 1 < checkName.length() && Character.isUpperCase(checkName.charAt(i + 1))) {
333+
result.append(' ');
334+
}
321335
}
322336
}
323337
return result.toString();

0 commit comments

Comments
 (0)