Skip to content

Commit

Permalink
add code smell types #54
Browse files Browse the repository at this point in the history
  • Loading branch information
pawlakm committed Jan 19, 2017
1 parent cf0453a commit a5a0d4c
Show file tree
Hide file tree
Showing 17 changed files with 589 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,22 @@ public enum SmellType {
* A method's implementation is missing.
*/
MISSING_IMPLEMENTATION,
/**
* An important test is missing.
*/
MISSING_TEST,
/**
* An important documentation is missing.
*/
MISSING_DOCUMENTATION,
/**
* A class or method has multiple responsibilities.
*/
MULTIPLE_RESPONSIBILITIES,
/**
* Non compliance with team or company development standards.
*/
NON_COMPLIANCE_WITH_STANDARDS,
/**
* Exception mechanism usage for non exceptional cases.
*/
Expand All @@ -80,6 +92,10 @@ public enum SmellType {
* The problem is solved one way throughout the system and the same problem is solved another way in the same system. One of the solutions is the oddball or the inconsistent solution and has to be eliminated.
*/
ODDBALL_SOLUTION,
/**
* Catch-all {@link SmellType} when you want to report an issue but can't find a corresponding {@link SmellType}.
*/
OTHER,
/**
* There is a way to simplify this algorithm.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* qualinsight-plugins-sonarqube-smell
* Copyright (c) 2015, QualInsight
* http://www.qualinsight.com/
*
* This program 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.
*
* This program 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, you can retrieve a copy
* from <http://www.gnu.org/licenses/>.
*/
package com.qualinsight.plugins.sonarqube.smell.plugin.check;

import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.check.Priority;
import org.sonar.check.Rule;
import org.sonar.squidbridge.annotations.SqaleLinearRemediation;
import org.sonar.squidbridge.annotations.SqaleSubCharacteristic;
import com.qualinsight.plugins.sonarqube.smell.api.model.SmellType;

/**
* Check for MISSING_DOCUMENTATION smell type.
*
* @author Michel Pawlak
*/
@Rule(key = "0024", name = "Missing documentation", description = "Mandatory documentation is missing.", priority = Priority.CRITICAL, tags = {
"documentation",
"todo"
})
@SqaleLinearRemediation(coeff = "1min", effortToFixDescription = "")
@SqaleSubCharacteristic(value = RulesDefinition.SubCharacteristics.ERRORS)
public class MissingDocumentationSmellCheck extends AbstractSmellCheck {

@Override
public SmellType smellType() {
return SmellType.MISSING_DOCUMENTATION;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* qualinsight-plugins-sonarqube-smell
* Copyright (c) 2015, QualInsight
* http://www.qualinsight.com/
*
* This program 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.
*
* This program 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, you can retrieve a copy
* from <http://www.gnu.org/licenses/>.
*/
package com.qualinsight.plugins.sonarqube.smell.plugin.check;

import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.check.Priority;
import org.sonar.check.Rule;
import org.sonar.squidbridge.annotations.SqaleLinearRemediation;
import org.sonar.squidbridge.annotations.SqaleSubCharacteristic;
import com.qualinsight.plugins.sonarqube.smell.api.model.SmellType;

/**
* Check for MISSING_TEST smell type.
*
* @author Michel Pawlak
*/
@Rule(key = "0025", name = "Missing test", description = "An important or critical test is missing.", priority = Priority.BLOCKER, tags = {
"tests",
"todo"
})
@SqaleLinearRemediation(coeff = "1min", effortToFixDescription = "")
@SqaleSubCharacteristic(value = RulesDefinition.SubCharacteristics.ERRORS)
public class MissingTestSmellCheck extends AbstractSmellCheck {

@Override
public SmellType smellType() {
return SmellType.MISSING_TEST;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* qualinsight-plugins-sonarqube-smell
* Copyright (c) 2015, QualInsight
* http://www.qualinsight.com/
*
* This program 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.
*
* This program 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, you can retrieve a copy
* from <http://www.gnu.org/licenses/>.
*/
package com.qualinsight.plugins.sonarqube.smell.plugin.check;

import org.sonar.check.Priority;
import org.sonar.check.Rule;
import org.sonar.squidbridge.annotations.SqaleLinearRemediation;
import org.sonar.squidbridge.annotations.SqaleSubCharacteristic;
import com.qualinsight.plugins.sonarqube.smell.api.model.SmellType;

/**
* Check for NON_CMOPLIANCE_WITH_STANDARDS smell type.
*
* @author Michel Pawlak
*/
@Rule(key = "0027", name = "Non compliance with standards", description = "The code does not comply with team or company development standards.", priority = Priority.CRITICAL, tags = {
"non-compliance"
})
@SqaleLinearRemediation(coeff = "1min", effortToFixDescription = "")
@SqaleSubCharacteristic(value = "COMPLIANCE")
public class NonComplianceWithStandardsSmellCheck extends AbstractSmellCheck {

@Override
public SmellType smellType() {
return SmellType.NON_COMPLIANCE_WITH_STANDARDS;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* qualinsight-plugins-sonarqube-smell
* Copyright (c) 2015, QualInsight
* http://www.qualinsight.com/
*
* This program 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.
*
* This program 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, you can retrieve a copy
* from <http://www.gnu.org/licenses/>.
*/
package com.qualinsight.plugins.sonarqube.smell.plugin.check;

import org.sonar.check.Priority;
import org.sonar.check.Rule;
import org.sonar.squidbridge.annotations.SqaleLinearRemediation;
import org.sonar.squidbridge.annotations.SqaleSubCharacteristic;
import com.qualinsight.plugins.sonarqube.smell.api.model.SmellType;

/**
* Check for OTHER smell type.
*
* @author Michel Pawlak
*/
@Rule(key = "0026", name = "Uncategorized smell", description = "Other smell that could not be categorized in any of the existing code smells types.", priority = Priority.MINOR, tags = {
"uncategorized"
})
@SqaleLinearRemediation(coeff = "1min", effortToFixDescription = "")
@SqaleSubCharacteristic(value = "MAINTAINABILITY_COMPLIANCE")
public class OtherSmellCheck extends AbstractSmellCheck {

@Override
public SmellType smellType() {
return SmellType.OTHER;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@
import com.qualinsight.plugins.sonarqube.smell.plugin.check.IndecentExposureSmellCheck;
import com.qualinsight.plugins.sonarqube.smell.plugin.check.MeaninglessCommentSmellCheck;
import com.qualinsight.plugins.sonarqube.smell.plugin.check.MiddleManSmellCheck;
import com.qualinsight.plugins.sonarqube.smell.plugin.check.MissingDocumentationSmellCheck;
import com.qualinsight.plugins.sonarqube.smell.plugin.check.MissingImplementationSmellCheck;
import com.qualinsight.plugins.sonarqube.smell.plugin.check.MissingTestSmellCheck;
import com.qualinsight.plugins.sonarqube.smell.plugin.check.MultipleResponsibilitiesSmellCheck;
import com.qualinsight.plugins.sonarqube.smell.plugin.check.NonComplianceWithStandardsSmellCheck;
import com.qualinsight.plugins.sonarqube.smell.plugin.check.NonExceptionSmellCheck;
import com.qualinsight.plugins.sonarqube.smell.plugin.check.OddballSolutionSmellCheck;
import com.qualinsight.plugins.sonarqube.smell.plugin.check.OtherSmellCheck;
import com.qualinsight.plugins.sonarqube.smell.plugin.check.OvercomplicatedAlgorithmSmellCheck;
import com.qualinsight.plugins.sonarqube.smell.plugin.check.PrimitivesObsessionSmellCheck;
import com.qualinsight.plugins.sonarqube.smell.plugin.check.RefusedBequestSmellCheck;
Expand Down Expand Up @@ -64,53 +68,116 @@ public final class SmellChecksRegistrar implements CheckRegistrar {
*/
static {
checkClasses = Lists.<Class<? extends JavaCheck>> newArrayList();
// 0001
checkClasses.add(AbbreviationsUsageSmellCheck.class);
// 0002
checkClasses.add(AntiPatternSmellCheck.class);
// 0003
checkClasses.add(BadDesignSmellCheck.class);
// 0004
checkClasses.add(BadFrameworkUsageSmellCheck.class);
// 0005
checkClasses.add(BadLoggingSmellCheck.class);
// 0006
checkClasses.add(HowCommentSmellCheck.class);
// 0007
checkClasses.add(IndecentExposureSmellCheck.class);
// 0008
checkClasses.add(MeaninglessCommentSmellCheck.class);
// 0009
checkClasses.add(MiddleManSmellCheck.class);
// 0010
checkClasses.add(MissingImplementationSmellCheck.class);
// 0011
checkClasses.add(MultipleResponsibilitiesSmellCheck.class);
// 0012
checkClasses.add(NonExceptionSmellCheck.class);
// 0013
checkClasses.add(OddballSolutionSmellCheck.class);
// 0014
checkClasses.add(OvercomplicatedAlgorithmSmellCheck.class);
// 0015
checkClasses.add(PrimitivesObsessionSmellCheck.class);
// 0016
checkClasses.add(RefusedBequestSmellCheck.class);
// 0017
checkClasses.add(ReinventedWheelSmellCheck.class);
// 0018
checkClasses.add(SolutionSprawlSmellCheck.class);
// 0019
checkClasses.add(SpeculativeGeneralitySmellCheck.class);
// 0020
checkClasses.add(UncommunicativeNameSmellCheck.class);
// 0021
checkClasses.add(UselessTestSmellCheck.class);
// 0022
checkClasses.add(WrongLanguageSmellCheck.class);
// 0023
checkClasses.add(WrongLogicSmellCheck.class);
// 0024
checkClasses.add(MissingDocumentationSmellCheck.class);
// 0025
checkClasses.add(MissingTestSmellCheck.class);
// 0026
checkClasses.add(OtherSmellCheck.class);
// 0027
checkClasses.add(NonComplianceWithStandardsSmellCheck.class);

testCheckClasses = Lists.<Class<? extends JavaCheck>> newArrayList();
// 0001
testCheckClasses.add(AbbreviationsUsageSmellCheck.class);
// 0002
testCheckClasses.add(AntiPatternSmellCheck.class);
// 0003
testCheckClasses.add(BadDesignSmellCheck.class);
// 0004
testCheckClasses.add(BadFrameworkUsageSmellCheck.class);
// 0005
testCheckClasses.add(BadLoggingSmellCheck.class);
// 0006
testCheckClasses.add(HowCommentSmellCheck.class);
// 0007
testCheckClasses.add(IndecentExposureSmellCheck.class);
// 0008
testCheckClasses.add(MeaninglessCommentSmellCheck.class);
// 0009
testCheckClasses.add(MiddleManSmellCheck.class);
// 0010
testCheckClasses.add(MissingImplementationSmellCheck.class);
// 0011
testCheckClasses.add(MultipleResponsibilitiesSmellCheck.class);
// 0012
testCheckClasses.add(NonExceptionSmellCheck.class);
// 0013
testCheckClasses.add(OddballSolutionSmellCheck.class);
// 0014
testCheckClasses.add(OvercomplicatedAlgorithmSmellCheck.class);
// 0015
testCheckClasses.add(PrimitivesObsessionSmellCheck.class);
// 0016
testCheckClasses.add(RefusedBequestSmellCheck.class);
// 0017
testCheckClasses.add(ReinventedWheelSmellCheck.class);
// 0018
testCheckClasses.add(SolutionSprawlSmellCheck.class);
// 0019
testCheckClasses.add(SpeculativeGeneralitySmellCheck.class);
// 0020
testCheckClasses.add(UncommunicativeNameSmellCheck.class);
// 0021
testCheckClasses.add(UselessTestSmellCheck.class);
// 0022
testCheckClasses.add(WrongLanguageSmellCheck.class);
// 0023
testCheckClasses.add(WrongLogicSmellCheck.class);
// 0024
testCheckClasses.add(MissingDocumentationSmellCheck.class);
// 0025
testCheckClasses.add(MissingTestSmellCheck.class);
// 0026
testCheckClasses.add(OtherSmellCheck.class);
// 0027
testCheckClasses.add(NonComplianceWithStandardsSmellCheck.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@
public final class SmellCountByTypeMeasuresComputer extends AbstractSmellMeasureComputer {

public static final List<String> SMELL_COUNT_INPUT_METRICS_KEYS = ImmutableList.of(SmellMetrics.SMELL_COUNT_ABBREVIATIONS_USAGE.getKey(), SmellMetrics.SMELL_COUNT_ANTI_PATTERN.getKey(),
SmellMetrics.SMELL_COUNT_BAD_DESIGN.getKey(), SmellMetrics.SMELL_COUNT_BAD_LOGGING.getKey(), SmellMetrics.SMELL_COUNT_HOW_COMMENT.getKey(),
SmellMetrics.SMELL_COUNT_INDECENT_EXPOSURE.getKey(), SmellMetrics.SMELL_COUNT_MEANINGLESS_COMMENT.getKey(), SmellMetrics.SMELL_COUNT_MIDDLE_MAN.getKey(),
SmellMetrics.SMELL_COUNT_MISSING_IMPLEMENTATION.getKey(), SmellMetrics.SMELL_COUNT_MULTIPLE_RESPONSIBILITIES.getKey(), SmellMetrics.SMELL_COUNT_NON_EXCEPTION.getKey(),
SmellMetrics.SMELL_COUNT_ODDBALL_SOLUTION.getKey(), SmellMetrics.SMELL_COUNT_OVERCOMPLICATED_ALGORITHM.getKey(), SmellMetrics.SMELL_COUNT_PRIMITIVES_OBSESSION.getKey(),
SmellMetrics.SMELL_COUNT_REFUSED_BEQUEST.getKey(), SmellMetrics.SMELL_COUNT_REINVENTED_WHEEL.getKey(), SmellMetrics.SMELL_COUNT_SOLUTION_SPRAWL.getKey(),
SmellMetrics.SMELL_COUNT_SPECULATIVE_GENERALITY.getKey(), SmellMetrics.SMELL_COUNT_UNCOMMUNICATIVE_NAME.getKey(), SmellMetrics.SMELL_COUNT_BAD_FRAMEWORK_USAGE.getKey(),
SmellMetrics.SMELL_COUNT_USELESS_TEST.getKey(), SmellMetrics.SMELL_COUNT_WRONG_LANGUAGE.getKey(), SmellMetrics.SMELL_COUNT_WRONG_LOGIC.getKey());
SmellMetrics.SMELL_COUNT_BAD_DESIGN.getKey(), SmellMetrics.SMELL_COUNT_BAD_LOGGING.getKey(), SmellMetrics.SMELL_COUNT_HOW_COMMENT.getKey(), SmellMetrics.SMELL_COUNT_INDECENT_EXPOSURE.getKey(),
SmellMetrics.SMELL_COUNT_MEANINGLESS_COMMENT.getKey(), SmellMetrics.SMELL_COUNT_MIDDLE_MAN.getKey(), SmellMetrics.SMELL_COUNT_MISSING_IMPLEMENTATION.getKey(),
SmellMetrics.SMELL_COUNT_MULTIPLE_RESPONSIBILITIES.getKey(), SmellMetrics.SMELL_COUNT_NON_EXCEPTION.getKey(), SmellMetrics.SMELL_COUNT_ODDBALL_SOLUTION.getKey(),
SmellMetrics.SMELL_COUNT_OVERCOMPLICATED_ALGORITHM.getKey(), SmellMetrics.SMELL_COUNT_PRIMITIVES_OBSESSION.getKey(), SmellMetrics.SMELL_COUNT_REFUSED_BEQUEST.getKey(),
SmellMetrics.SMELL_COUNT_REINVENTED_WHEEL.getKey(), SmellMetrics.SMELL_COUNT_SOLUTION_SPRAWL.getKey(), SmellMetrics.SMELL_COUNT_SPECULATIVE_GENERALITY.getKey(),
SmellMetrics.SMELL_COUNT_UNCOMMUNICATIVE_NAME.getKey(), SmellMetrics.SMELL_COUNT_BAD_FRAMEWORK_USAGE.getKey(), SmellMetrics.SMELL_COUNT_USELESS_TEST.getKey(),
SmellMetrics.SMELL_COUNT_WRONG_LANGUAGE.getKey(), SmellMetrics.SMELL_COUNT_WRONG_LOGIC.getKey(), SmellMetrics.SMELL_COUNT_MISSING_DOCUMENTATION.getKey(),
SmellMetrics.SMELL_COUNT_MISSING_TEST.getKey(), SmellMetrics.SMELL_COUNT_OTHER.getKey(), SmellMetrics.SMELL_COUNT_NON_COMPLIANCE_WITH_STANDARDS.getKey());

public static final List<String> SMELL_COUNT_OUTPUT_METRICS_KEYS = ImmutableList.copyOf(SMELL_COUNT_INPUT_METRICS_KEYS);

Expand Down
Loading

0 comments on commit a5a0d4c

Please sign in to comment.