Skip to content

Commit ec9a896

Browse files
gaurabdgmuhlba91
authored andcommitted
minor: methods and variable renaming
1 parent ea3e795 commit ec9a896

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public void updateRulesWithMetadata() {
6868
final ModuleDetails moduleDetails = metadataRepo.get(rule.key());
6969
if (moduleDetails != null) {
7070
rule.setHtmlDescription(moduleDetails.getDescription());
71-
rule.setName(convertName(moduleDetails.getName() + CHECK_STRING));
72-
rule.setInternalKey(convertInternalKey(moduleDetails));
71+
rule.setName(getFullCheckName(moduleDetails.getName() + CHECK_STRING));
72+
rule.setInternalKey(getInternalKey(moduleDetails));
7373

7474
rule.params().forEach(param -> { //NOSONAR
7575
if (!"tabWidth".equals(param.key())) {
@@ -110,8 +110,8 @@ public void createRulesWithMetadata() {
110110
final RulesDefinition.NewRule rule =
111111
repository.createRule(moduleDetails.getFullQualifiedName());
112112
rule.setHtmlDescription(moduleDetails.getDescription())
113-
.setName(convertName(moduleDetails.getName() + CHECK_STRING))
114-
.setInternalKey(convertInternalKey(moduleDetails))
113+
.setName(getFullCheckName(moduleDetails.getName() + CHECK_STRING))
114+
.setInternalKey(getInternalKey(moduleDetails))
115115
.setDebtRemediationFunction(debtRemediationFunction)
116116
.setSeverity("MINOR")
117117
.setStatus(RuleStatus.READY);
@@ -150,8 +150,8 @@ private boolean isTemplateRule(String checkName) {
150150
.anyMatch(CheckstyleMetadata::isSetter);
151151
}
152152

153-
private List<String> getEnumValues(String checkName) {
154-
final Class<?> loadedClass = getClass(checkName);
153+
private List<String> getEnumValues(String enumName) {
154+
final Class<?> loadedClass = getClass(enumName);
155155
final Object[] vals = loadedClass.getEnumConstants();
156156
final List<String> enumVals = new ArrayList<>();
157157
for (Object val : vals) {
@@ -254,22 +254,22 @@ public static boolean isSetter(Method method) {
254254
* It converts the name received from ModuleDetails to Sonar rule name format
255255
* e.g. RightCurlyCheck -> Right Curly Check
256256
*
257-
* @param name the name fetched from ModuleDetails
257+
* @param checkName the name fetched from ModuleDetails
258258
* @return modifiedName
259259
*/
260-
public static String convertName(String name) {
260+
public static String getFullCheckName(String checkName) {
261261
final int capacity = 1024;
262262
final StringBuilder result = new StringBuilder(capacity);
263-
for (int i = 0; i < name.length(); i++) {
264-
result.append(name.charAt(i));
265-
if (i + 1 < name.length() && Character.isUpperCase(name.charAt(i + 1))) {
263+
for (int i = 0; i < checkName.length(); i++) {
264+
result.append(checkName.charAt(i));
265+
if (i + 1 < checkName.length() && Character.isUpperCase(checkName.charAt(i + 1))) {
266266
result.append(' ');
267267
}
268268
}
269269
return result.toString();
270270
}
271271

272-
public static String convertInternalKey(ModuleDetails moduleDetails) {
272+
public static String getInternalKey(ModuleDetails moduleDetails) {
273273
String result = "Checker/";
274274
if ("com.puppycrawl.tools.checkstyle.Checker".equals(moduleDetails.getParent())) {
275275
result += moduleDetails.getName();

src/test/java/org/sonar/plugins/checkstyle/metadata/CheckstyleMetadataTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ public void testUpdate() {
7070
assertEquals("HTML Descriptions don't match", moduleDetails.getDescription(),
7171
sampleCheckRule.htmlDescription());
7272
assertEquals("Name doesn't match",
73-
CheckstyleMetadata.convertName(moduleDetails.getName() + "Check"),
73+
CheckstyleMetadata.getFullCheckName(moduleDetails.getName() + "Check"),
7474
sampleCheckRule.name());
7575
assertEquals("InternalKey doesn't match",
76-
CheckstyleMetadata.convertInternalKey(moduleDetails),
76+
CheckstyleMetadata.getInternalKey(moduleDetails),
7777
sampleCheckRule.internalKey());
7878
sampleCheckRule.params().forEach(param -> {
7979
if (!"tabWidth".equals(param.key())) {

0 commit comments

Comments
 (0)