Every piece of code is different in terms of domain, context, and its quality requirements. Measuring quality aspects of all the software systems using the same stick is not appropriate and often not desirable. Keeping it in mind, Designite has introduced a new feature “Preferences” in version 1.33.0 to allow users to customize their analysis by selecting thresholds based on their context and requirements.
Metric threshold customization
You can now select one of the metric threshold profiles. Designite offers four such profiles – Standard, Stringent, Lenient, and Custom. As the name suggests, Standard profile is the default option with balanced metric thresholds. By selecting Stringent, you can enable stricter metric thresholds. Similarly, Lenient profile imposes lenient metric thresholds. If none of these profiles suits your needs, you can choose Custom profile and change any metric to your desired value.
Customize Smell Detection
You can completely customize the design and implementation smell detection in Designite. You can enable/disable smells i.e. whether you want Designite to detect specific smells or not. In many cases, there are multiple thresholds associated with a smell. You can change the threshold values based on your requirements. Certain threshold values are fixed (for example, “number of methods” in the case of Imperative Abstraction which is intentional to preserve the essence of the smell).
If you see an error something like the following, then either you need to execute the tool with administrative privileges or manually change the configuration files.
Custom Analysis using Console Application
If you are using Designite’s console application, you can specify your desired threshold settings very easily.
For metric profile and threshold values, open “MetricThreshold.config” file in the installation folder of Designite (if the file doesn’t exist, create one). Put the following line in the file:
If you want to change the profile to Lenient, put “LENIENT” instead of “STRINGENT”.
In case, you wish to customize one or more threshold values, your file may look like as follows:
MetricThresholdProfile=CUSTOM CC=7 LOC=500 DIT=4 FANIN=15 FANOUT=15 LCOM=0.9 MLOC=60 NC=7 NOF=10 NOM=20 NOP=10 NOPF=1 NOPM=10 PC=4 WMC=60
Similarly, to customize your smell analysis, open “SmellThreshold.config” in the installation folder of Designite. Create the file if it doesn’t exist. Paste the following contents in the file:
UNNECESSARY ABSTRACTION=NO,5 IMPERATIVE ABSTRACTION=NO,100 MULTIFACETED ABSTRACTION=NO,0.6,10,10 UNUTILIZED ABSTRACTION=YES DUPLICATE ABSTRACTION=YES,20 DEFICIENT ENCAPSULATION=YES,1,1 UNEXPLOITED ENCAPSULATION=YES,2 BROKEN MODULARIZATION=YES,5 INSUFFICIENT MODULARIZATION=YES,20,30,100 HUB-LIKE MODULARIZATION=YES,20,20 CYCLICALLY-DEPENDENT MODULARIZATION=NO WIDE HIERARCHY=YES,10 DEEP HIERARCHY=YES,6 MULTIPATH HIERARCHY=YES CYCLIC HIERARCHY=YES REBELLIOUS HIERARCHY=YES UNFACTORED HIERARCHY=YES MISSING HIERARCHY=YES,2 BROKEN HIERARCHY=YES LONG METHOD=YES,100 COMPLEX METHOD=YES,8 LONG PARAMETER LIST=YES,5 LONG IDENTIFIER=YES,30 LONG STATEMENT=NO,120 COMPLEX CONDITIONAL=YES,3 VIRTUAL CALL FROM CONSTRUCTOR=YES EMPTY CATCH BLOCK=YES MAGIC NUMBER=YES DUPLICATE CODE=YES MISSING DEFAULT=YES
Each line contains the information about one smell. At the minimum, each line contains whether the smell will be detected by the tool (obviously, yes means the tool will look for the smell). A smell may have zero or more threshold values; the number of thresholds depends on the smell. You can change the threshold values based on your requirements. Please note that the order of the smells can be changed; thus, Multifaceted Abstraction can come first and Unnecessary Abstraction can appear in the last line.
Here is the table that summarizes the customizable thresholds for each smell.
|UNNECESSARY ABSTRACTION||Enable analysis – YES/NO
Max no of fields + properties
|IMPERATIVE ABSTRACTION||Enable analysis – YES/NO
|MULTIFACETED ABSTRACTION||Enable analysis – YES/NO
Min no of fields
Min no of methods
|UNUTILIZED ABSTRACTION||Enable analysis – YES/NO|
|DUPLICATE ABSTRACTION||Enable analysis – YES/NO
Min consecutive duplicated lines
|DEFICIENT ENCAPSULATION||Enable analysis – YES/NO
Min no of public fields
Min no of public static fields
|UNEXPLOITED ENCAPSULATION||Enable analysis – YES/NO
Min no of typechecks belonging to same hierarchy
|BROKEN MODULARIZATION||Enable analysis – YES/NO
Min no of fields + properties
|INSUFFICIENT MODULARIZATION||Enable analysis – YES/NO
Min no of public methods
Min no of all methods
|HUB-LIKE MODULARIZATION||Enable analysis – YES/NO
|CYCLICALLY-DEPENDENT MODULARIZATION||Enable analysis – YES/NO|
|WIDE HIERARCHY||Enable analysis – YES/NO
Min no of subtypes
|DEEP HIERARCHY||Enable analysis – YES/NO
|MULTIPATH HIERARCHY||Enable analysis – YES/NO|
|CYCLIC HIERARCHY||Enable analysis – YES/NO|
|REBELLIOUS HIERARCHY||Enable analysis – YES/NO|
|UNFACTORED HIERARCHY||Enable analysis – YES/NO|
|MISSING HIERARCHY||Enable analysis – YES/NO
Min no of typechecks
|BROKEN HIERARCHY||Enable analysis – YES/NO|
|LONG METHOD||Enable analysis – YES/NO
Min method LOC
|COMPLEX METHOD||Enable analysis – YES/NO
|LONG PARAMETER LIST||Enable analysis – YES/NO
Min parameter count
|LONG IDENTIFIER||Enable analysis – YES/NO
Min identifier length
|LONG STATEMENT||Enable analysis – YES/NO
Min statement length
|COMPLEX CONDITIONAL||Enable analysis – YES/NO
Min no of conditionals
|VIRTUAL CALL FROM CONSTRUCTOR||Enable analysis – YES/NO|
|EMPTY CATCH BLOCK||Enable analysis – YES/NO|
|MAGIC NUMBER||Enable analysis – YES/NO|
|DUPLICATE CODE||Enable analysis – YES/NO|
|MISSING DEFAULT||Enable analysis – YES/NO|