Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 165 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Ignore code quality reports
*.csv
*.txt

# Ignore specific folders
pyrasbt/
alpyproj/
Expand Down Expand Up @@ -54,4 +58,165 @@ docs/_build/

*.egg-info/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ A comprehensive Python code quality analysis tool that detects code smells, arch

### Install from source
```bash
Download the repository
# Download the repository
cd "the_repository"
# Activate the virtual environment
python3 -m venv venv
# Instal the dependencies
pip install -e .
```

Expand Down
536 changes: 0 additions & 536 deletions code_analysis.log

This file was deleted.

4 changes: 4 additions & 0 deletions code_quality_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ code_smells:
value: 4
explanation: "Abstract classes with no concrete implementations may indicate speculative generality."

UNUSED_PARAMETERS_THRESHOLD:
value: 2
explanation: "The minimun allowed number of unused parameters"

MIDDLE_MAN_RATIO:
value: 0.5
explanation: "Classes where more than this ratio of methods simply delegate to another class may be middle men."
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"networkx",
"pyyaml",
"pytest",
"tqdm"
],
entry_points={
"console_scripts": [
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 12 additions & 1 deletion src/code_quality_analyzer/architectural_smell_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
import sys
import importlib.util
import logging

from code_quality_analyzer.const import IGNORE_PATHS
from .exceptions import CodeAnalysisError
from tqdm import tqdm

# Set up logger
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -90,7 +93,7 @@ def detect_smells(self, directory_path):
self.analyze_directory(directory_path)

# Then run each detection method
for detect_method, method_name in detection_methods:
for detect_method, method_name in tqdm(detection_methods):
try:
logger.debug(f"Running {method_name}")
detect_method()
Expand Down Expand Up @@ -118,6 +121,14 @@ def analyze_directory(self, directory_path):
"""
for root, _, files in os.walk(directory_path):
for file in files:
go = True
for ignored_path in IGNORE_PATHS.split(","):
if ignored_path in os.path.join(root, file):
print(f"Ignored {os.path.join(root, file)}")
go = False
break
if not go:
continue
if file.endswith('.py'):
file_path = os.path.join(root, file)
self.analyze_file(file_path)
Expand Down
1 change: 1 addition & 0 deletions src/code_quality_analyzer/const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IGNORE_PATHS = "venv,tox,uml,log,pycache,scripts,test,nori"
10 changes: 10 additions & 0 deletions src/code_quality_analyzer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import argparse
import csv
import logging

from code_quality_analyzer.const import IGNORE_PATHS
from .code_smell_detector import CodeSmellDetector
from .architectural_smell_detector import ArchitecturalSmellDetector
from .structural_smell_detector import StructuralSmellDetector
Expand Down Expand Up @@ -38,6 +40,14 @@ def analyze_code_smells(directory_path, detector):

for root, _, files in os.walk(directory_path):
for file in files:
go = True
for ignored_path in IGNORE_PATHS.split(","):
if ignored_path in os.path.join(root, file):
print(f"Ignored {os.path.join(root, file)}")
go = False
break
if not go:
continue
if file.endswith('.py'):
file_path = os.path.join(root, file)
try:
Expand Down
10 changes: 10 additions & 0 deletions src/code_quality_analyzer/structural_smell_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from dataclasses import dataclass
import yaml
import logging

from code_quality_analyzer.const import IGNORE_PATHS
from .exceptions import CodeAnalysisError

# Set up logger
Expand Down Expand Up @@ -149,6 +151,14 @@ def analyze_directory(self, directory_path):

for root, _, files in os.walk(directory_path):
for file in files:
go = True
for ignored_path in IGNORE_PATHS.split(","):
if ignored_path in os.path.join(root, file):
print(f"Ignored {os.path.join(root, file)}")
go = False
break
if not go:
continue
if file.endswith('.py'):
file_path = os.path.join(root, file)
try:
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.