smell_detek 0.1.1

A CLI tool for detecting code smells in Dart and Flutter projects. Developed by radinaldn

smell_detek by radinaldn

smell_detek is a Dart package for detecting common code smells in Dart and Flutter projects, with a focus on identifying God Classes. It provides configurable thresholds for various metrics like Access to Foreign Data (ATFD), Weighted Method Count (WMC), and Tight Class Cohesion (TCC).

Features

  • Detects God Classes based on customizable thresholds.
  • Supports configuration via a YAML file.
  • Can be run as a CLI tool for easy integration into existing projects.

Installation

To use smell_detek as a CLI tool, you need to install it globally:

dart pub global activate smell_detek

Usage

Running the CLI Tool

Once the package is installed globally, you can run the tool by specifying the path to the directory you want to analyze and the path to your configuration file.

smell_detek /path/to/your/project /path/to/smell_detek_config.yaml

Example Command

Let's say you have a Flutter project located at /home/user/my_flutter_app and a configuration file at /home/user/config/smell_detek_config.yaml. You would run:

smell_detek /home/user/my_flutter_app/lib /home/user/config/smell_detek_config.yaml

This command will analyze all the Dart files in the lib directory of your Flutter project, using the thresholds defined in the smell_detek_config.yaml file.

Example Configuration File

# smell_detek_config.yaml

god_class_detector:
  atfd_threshold: 5         # Access to Foreign Data threshold (default: 3)
  wmc_threshold: 50         # Weighted Method Count threshold (default: 47)
  tcc_threshold: 0.33       # Tight Class Cohesion threshold (default: 0.33)

Default Thresholds

If you do not provide a configuration file, the tool will use the following default thresholds:

  • ATFD (Access to Foreign Data): 3
  • WMC (Weighted Method Count): 47
  • TCC (Tight Class Cohesion): 0.33

Output

When the tool detects a God Class, it will output a message like this:

This output provides a quick overview of the metrics that led to the classification of the class as a God Class.```