Skip to content

Latest commit

 

History

History
64 lines (49 loc) · 3.27 KB

README.md

File metadata and controls

64 lines (49 loc) · 3.27 KB

GetSmells

GetSmells extracts code smells from Java source code using the Understand API.

Prerequisites

GetSmells is written to work on either Windows or MacOS (tested on Windows 7 and MacOS 10.12)

  • Understand: You must have Understand installed locally to run the script.
    • It should be installed in the default location for your OS (C:\Program Files\SciTools\ for Windows or /Applications/Understand.app on MacOS); if it is not in the default location, you can modify the paths at the top of both understandapi.py and understandcli.py.
    • You can request 1-year educational license for Understand here
  • Python 3.4+: The script is written for Python 3.4+ and, on Windows, your 32-bit/64-bit version of Python 3 should match the bit-ness of your Understand install (developed using Python 3.6 64-bit)
  • Python Libraries
    • NumPy: pip3 install numpy

Usage

python3 getsmells.py [sourcePath] [outputPath (optional)]

Example
python3 getsmells.py c:/Users/you/path/to/code c:/Users/you/output

Parameters
sourcePath: The path to the directory with a single project's code
outputPath: The directory to output the CSVs with code smells (one for class-level and one for method-level), the debug output (log), the Understand Project, the list of classes/methods with each smell (default: create a new subdirectory in the current directory)

Smells

Some extracted smells are based off the criteria outlined in Object-Oriented Metrics in Practice by Michele Lanza and Radu Marinescu, while others are described in On the diffuseness and the impact on maintainability of code smells: a large scale empirical investigation.

God Class (Class-Level)

  • ATFD (Access to Foreign Data) > Few
  • WMC (Weighted Method Count) >= Very High
  • TCC (Tight Class Cohesion) < 1/3

Lazy Class (Class-Level)

  • LOC (Lines of Code) < 1st quartile of system

Complex Class (Class-Level)

  • CMC (Complex Method Count) > 1

Long Method (Method-Level)

  • LOC (Lines of Code) > mean of system

Files

getsmells.py: "Main" file used to run GetSmells; contains the GetSmells command-line interface
understandcli.py: Interacts with the Understand command-line interface (CLI); creates and Understand project with a given source code directory and starts Understands analysis
understandapi.py: Interacts with the Understand Python API to extract information from the Understand project; calculates each custom ("complex") metric and applies thresholds to determine which classes/methods are subject to code smells

Useful Links

Understand API Documentation

Understand CLI Documentation