A Python package for RefaClass
Project description
refa-class
Single Responsibility Principle checker
Description
This library detects classes in your source code that may violate the Single Responsibility Principle. If a method does not exist in a class, that class is 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.txtrun 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.5you can use Visual Studio Code Dev Containers extension to create container
Executing program
-
you can check python
classjust 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
OKClasses that are not considered to violate the Single Responsibility PrincipleNGClasses 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]
- refaclass-[directory 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
Truethen the content of the section is considered a file (if set toFalseor nois_fileparameters then class) - is_dir: if set to
Truethen the content of the section is considered a directory (if set toFalseor nois_fileparameters then class)
Example
[refaclass-test_.*.py]
is_file = True
ignore_checks = True
[refaclass-Test.*]
ignore_checks = True
[refaclass-tests/test_core.*]
is_dir = True
ignore_checks = True
Author
Version History
License
This project is licensed under the MIT License - see the LICENSE file for details
Reference paper
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file refaclass-2.3.0.tar.gz.
File metadata
- Download URL: refaclass-2.3.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ed9fa04cabd8f17c844007d5683423b87cb5c0a840ccab84635bcd4b10e80a4
|
|
| MD5 |
0c523d2a15726e275ff55bba9a64141c
|
|
| BLAKE2b-256 |
c3f45a673ac5f047af989b9d54b3c9c2140b388dfd1bc36ebeba7ee74992105a
|
File details
Details for the file refaclass-2.3.0-py3-none-any.whl.
File metadata
- Download URL: refaclass-2.3.0-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3df5c9f1550ecbeb5174fcff10d1cf10a68b2f0f3f55da32586d1ce35a4aa6da
|
|
| MD5 |
6566b9a4042e9d7e7b69c06fa0ec275b
|
|
| BLAKE2b-256 |
587394240b8c0824a3e66180a3fabb03068faaa8e2da1e392e27fdc8bc8af00c
|