Metadata-Version: 2.1
Name: refaclass
Version: 2.2.0
Summary: A Python package for RefaClass
Home-page: https://github.com/hirokazuniimoto/refa-class
Author: Hirokazu Niimoto
License: MIT
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.8
Classifier: License :: OSI Approved :: MIT License
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fasttext (==0.9.2)
Requires-Dist: gdown (==4.7.1)
Requires-Dist: gensim (==4.3.2)
Requires-Dist: joblib (==1.3.2)
Requires-Dist: numpy (==1.24.4)
Requires-Dist: pandas (==2.0.3)
Requires-Dist: pybind11 (==2.11.1)
Requires-Dist: pyclustering (==0.10.1.2)
Requires-Dist: python-dateutil (==2.8.2)
Requires-Dist: pytz (==2023.3)
Requires-Dist: scikit-learn (==1.3.0)
Requires-Dist: scipy (==1.10.1)
Requires-Dist: six (==1.16.0)
Requires-Dist: threadpoolctl (==3.2.0)
Requires-Dist: tzdata (==2023.3)
Requires-Dist: tqdm (==4.66.1)

[![<ORG_NAME>](https://circleci.com/gh/hirokazuniimoto/refa-class.svg?style=svg)](https://app.circleci.com/pipelines/github/hirokazuniimoto/refa-class)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/refaclass)

# refa-class

`Single Responsibility Principle` checker

## Description

This library detects classes in your source code that may violate the "Single Responsibility Principle". If the method does not exist in the class it will be ignored.

## Getting Started

### Notice
* The first run will take some time as the model needs to be downloaded.

### Installing
* refa-class can be installed using pip:
    ```
    pip install refaclass
    ```

* local environment  
  If you want to run the code locally, or change or modify it, you can install from the repo directly:
  ```
  git clone https://github.com/hirokazuniimoto/refa-class.git  
  cd refa-class  
  pip install -r requirements.txt
  pip install -r requirements.dev.txt
  ```

  run in local environment
  
  ```
  python3 -m refaclass.main

  The following arguments are optional:
  -d --dir            directory path
  -o --output         output [terminal csv]
  -t --threshold      cosine similarity threshold between [method and method] [class and method] (detects below threshold) default: 0.5
  ```

  you can use [Visual Studio Code Dev Containers extension](https://code.visualstudio.com/docs/remote/containers) to create container

### Executing program

* you can check python `class` just like this:

  ```
  cd [project]
  refaclass

  The following arguments are optional:
    -d --dir            directory path
    -o --output         output [terminal csv]
    -t --threshold      cosine similarity threshold between [method and method] [class and method] (detects below threshold) default: 0.5
  ```

### Result

* `OK` Classes that are not considered to violate the Single Responsibility Principle
* `NG` Classes considered to violate the Single Responsibility Principle
  * Show detected methods

## Test

* run test
```
python -m unittest discover tests
```
* measure coverage
```
python -m coverage run -m unittest discover tests
python -m coverage report -m
```

## Setting File
This project utilizes configuration files `refaclass.ini` to customize its behavior and settings. Configuration files play a crucial role in tailoring the application to your specific needs. 

* File Location: The configuration files arelocated at the root of the project.

### Configuration Sections
* refaclass-[class name]
* refaclass-[file name]

you can also use regular expressions

### Configuration Parameters
* ignore_checks: if set to `True`,  ignore file or class specified in that section
* is_file: if set to `True` then the content of the section is considered a file (if set to `False` or no `is_file` parameters then class)

### Example
```
[refaclass-test_.*.py]
is_file = True
ignore_checks = True

[refaclass-Test.*]
ignore_checks = True
```

## Author
[Hirokazu Niimoto](https://github.com/hirokazuniimoto)

## Version History

* 1.5.1
    * [GitHub](https://github.com/hirokazuniimoto/refa-class/releases/tag/1.5.1)
    * [PyPI](https://pypi.org/project/refaclass/1.5.1/)
* 2.0.1
    * [GitHub]()
    * [PyPI]()

## License

This project is licensed under the MIT License - see the LICENSE file for details

## Reference paper
* [ソフトウェア設計のSOLID原則に基づく単一責任の原則違反を検出するための自然言語処理ツールの提案と評価（仮）]()
* [自然言語処理を用いたデータベーススキーマの再構成支援ツールの開発](https://www.jstage.jst.go.jp/article/jssst/39/2/39_2_29/_pdf/-char/ja)

