Skip to content

Commit

Permalink
Requirements upgrade (#21)
Browse files Browse the repository at this point in the history
Updated versions of dependencies
Added django dictionary support
Fixed tests
  • Loading branch information
GirZ0n authored Apr 14, 2021
1 parent 809a8f6 commit 3df4664
Show file tree
Hide file tree
Showing 43 changed files with 116 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=.git,__pycache__,docs/source/conf.py,old,build,dist,venv,test/resources,.eggs,review.egg-info,.pytest_cache,node_modules
# TODO: change max-complexity into 10 after refactoring
flake8 . --count --max-complexity=11 --max-line-length=120 --max-doc-length=120 --ignore=I201,I202,I101,I100,R504,A003,E800,SC200,SC100,E402,W503,WPS,H601 --statistics --exclude=.git,__pycache__,docs/source/conf.py,old,build,dist,venv,test/resources,.eggs,review.egg-info,.pytest_cache,node_modules
flake8 . --count --max-complexity=11 --max-line-length=120 --max-doc-length=120 --ignore=R504,A003,E800,E402,W503,WPS,H601 --statistics --exclude=.git,__pycache__,docs/source/conf.py,old,build,dist,venv,test/resources,.eggs,review.egg-info,.pytest_cache,node_modules
- name: Set up Eslint
run: |
npm install eslint --save-dev
Expand Down
10 changes: 5 additions & 5 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pytest~=5.4.3
pytest~=6.2.3
pytest-runner
pytest-subtests
jsonschema==3.2.0
Django~=3.0.8
pylint~=2.5.3
requests~=2.24.0
setuptools~=47.3.1
Django~=3.2
pylint~=2.7.4
requests~=2.25.1
setuptools~=56.0.0
24 changes: 12 additions & 12 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
setuptools==47.3.1
setuptools==56.0.0

# python code analysis tools
pylint==2.5.3
pylint-django==2.0.15
flake8==3.8.3
pylint==2.7.4
pylint-django==2.3.0
flake8==3.9.0

# flake8 plugins
flake8-bugbear==20.1.4
flake8-bugbear==21.4.3
flake8-builtins==1.5.3
flake8-comprehensions==3.2.3
flake8-eradicate==0.4.0
flake8-comprehensions==3.4.0
flake8-eradicate==1.0.0
flake8-import-order==0.18.1
flake8-plugin-utils==1.3.0
flake8-plugin-utils==1.3.1
flake8-polyfill==1.0.2
flake8-return==1.1.1
flake8-spellcheck==0.14.0
flake8-return==1.1.2
flake8-spellcheck==0.24.0
mccabe==0.6.1
pep8-naming==0.11.1
wps-light==0.15.2
Expand All @@ -25,5 +25,5 @@ cohesion==1.0.0
radon==4.5.0

# extra libraries and frameworks
django==3.0.8
requests==2.24.0
django==3.2
requests==2.25.1
2 changes: 1 addition & 1 deletion src/python/review/application_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass
from enum import Enum, unique
from typing import Optional, Set, List
from typing import List, Optional, Set

from src.python.review.inspectors.inspector_type import InspectorType

Expand Down
2 changes: 1 addition & 1 deletion src/python/review/common/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from contextlib import contextmanager
from enum import Enum, unique
from pathlib import Path
from typing import List, Union, Callable
from typing import Callable, List, Union


@unique
Expand Down
3 changes: 3 additions & 0 deletions src/python/review/inspectors/flake8/.flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
[flake8]
disable_noqa=True

dictionaries=en_US,python,technical,django

ignore=W291, # trailing whitespaces
W292, # no newline at end of file
W293, # blank line contains whitespaces
Expand Down
6 changes: 3 additions & 3 deletions src/python/review/inspectors/flake8/flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

from src.python.review.common.subprocess_runner import run_in_subprocess
from src.python.review.inspectors.base_inspector import BaseInspector
from src.python.review.inspectors.common import convert_percentage_of_value_to_lack_of_value
from src.python.review.inspectors.flake8.issue_types import CODE_PREFIX_TO_ISSUE_TYPE, CODE_TO_ISSUE_TYPE
from src.python.review.inspectors.inspector_type import InspectorType
from src.python.review.inspectors.issue import (
BaseIssue,
CodeIssue,
CohesionIssue,
CyclomaticComplexityIssue,
IssueType,
IssueData,
CohesionIssue,
IssueType,
)
from src.python.review.inspectors.tips import get_cyclomatic_complexity_tip
from src.python.review.inspectors.common import convert_percentage_of_value_to_lack_of_value

logger = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
from typing import Dict

from src.python.review.inspectors.issue import IssueType

from src.python.review.inspectors.intellij.issue_types.java import (
ISSUE_CLASS_TO_ISSUE_TYPE as JAVA_ISSUE_CLASS_TO_ISSUE_TYPE,
)

from src.python.review.inspectors.intellij.issue_types.kotlin import (
ISSUE_CLASS_TO_ISSUE_TYPE as KOTLIN_ISSUE_CLASS_TO_ISSUE_TYPE,
)

from src.python.review.inspectors.intellij.issue_types.python import (
ISSUE_CLASS_TO_ISSUE_TYPE as PYTHON_ISSUE_CLASS_TO_ISSUE_TYPE,
)
from src.python.review.inspectors.issue import IssueType

ISSUE_CLASS_TO_ISSUE_TYPE: Dict[str, IssueType] = {
**JAVA_ISSUE_CLASS_TO_ISSUE_TYPE,
Expand Down
6 changes: 2 additions & 4 deletions src/python/review/inspectors/parsers/checkstyle_parser.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import logging
import re
from pathlib import Path
from typing import Callable, Dict, List, Any, Optional
from typing import Any, Callable, Dict, List, Optional
from xml.etree import ElementTree

from src.python.review.common.file_system import get_content_from_file
from src.python.review.inspectors.inspector_type import InspectorType

from src.python.review.inspectors.issue import (
BaseIssue,
BoolExprLenIssue,
CodeIssue,
CyclomaticComplexityIssue,
FuncLenIssue,
IssueData,
IssueType,
LineLenIssue,
IssueData,
)

from src.python.review.inspectors.tips import (
get_bool_expr_len_tip,
get_cyclomatic_complexity_tip,
Expand Down
2 changes: 1 addition & 1 deletion src/python/review/inspectors/radon/radon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

from src.python.review.common.subprocess_runner import run_in_subprocess
from src.python.review.inspectors.base_inspector import BaseInspector
from src.python.review.inspectors.common import convert_percentage_of_value_to_lack_of_value
from src.python.review.inspectors.inspector_type import InspectorType
from src.python.review.inspectors.issue import BaseIssue, IssueData, IssueType, MaintainabilityLackIssue
from src.python.review.inspectors.common import convert_percentage_of_value_to_lack_of_value
from src.python.review.inspectors.tips import get_maintainability_index_tip


Expand Down
6 changes: 2 additions & 4 deletions src/python/review/inspectors/springlint/springlint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import re
from pathlib import Path
from shutil import copy
from typing import AnyStr, List, Optional, Dict, Any
from typing import Any, AnyStr, Dict, List, Optional

from src.python.review.common.file_system import new_temp_dir
from src.python.review.common.subprocess_runner import run_in_subprocess
from src.python.review.inspectors.base_inspector import BaseInspector
from src.python.review.inspectors.inspector_type import InspectorType

from src.python.review.inspectors.issue import (
BaseIssue,
ChildrenNumberIssue,
Expand All @@ -18,12 +17,11 @@
CohesionIssue,
CouplingIssue,
InheritanceIssue,
IssueData,
IssueType,
MethodNumberIssue,
WeightedMethodIssue,
IssueData,
)

from src.python.review.inspectors.tips import (
get_child_number_tip,
get_class_coupling_tip,
Expand Down
16 changes: 8 additions & 8 deletions src/python/review/quality/evaluate_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
)
from src.python.review.quality.rules.class_response_scoring import LANGUAGE_TO_RESPONSE_RULE_CONFIG, ResponseRule
from src.python.review.quality.rules.code_style_scoring import CodeStyleRule, LANGUAGE_TO_CODE_STYLE_RULE_CONFIG
from src.python.review.quality.rules.cohesion_scoring import (
CohesionRule,
LANGUAGE_TO_COHESION_RULE_CONFIG,
)
from src.python.review.quality.rules.coupling_scoring import CouplingRule, LANGUAGE_TO_COUPLING_RULE_CONFIG
from src.python.review.quality.rules.cyclomatic_complexity_scoring import (
CyclomaticComplexityRule,
Expand All @@ -28,6 +32,10 @@
LANGUAGE_TO_INHERITANCE_DEPTH_RULE_CONFIG,
)
from src.python.review.quality.rules.line_len_scoring import LANGUAGE_TO_LINE_LENGTH_RULE_CONFIG, LineLengthRule
from src.python.review.quality.rules.maintainability_scoring import (
LANGUAGE_TO_MAINTAINABILITY_RULE_CONFIG,
MaintainabilityRule,
)
from src.python.review.quality.rules.method_number_scoring import (
LANGUAGE_TO_METHOD_NUMBER_RULE_CONFIG,
MethodNumberRule,
Expand All @@ -37,14 +45,6 @@
WeightedMethodsRule,
)
from src.python.review.reviewers.utils.code_statistics import CodeStatistics
from src.python.review.quality.rules.cohesion_scoring import (
LANGUAGE_TO_COHESION_RULE_CONFIG,
CohesionRule,
)
from src.python.review.quality.rules.maintainability_scoring import (
LANGUAGE_TO_MAINTAINABILITY_RULE_CONFIG,
MaintainabilityRule,
)


def __get_available_rules(language: Language) -> List[Rule]:
Expand Down
2 changes: 1 addition & 1 deletion src/python/review/quality/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def quality_type(self) -> QualityType:
def next_quality_type(self) -> QualityType:
return min(map(lambda rule: rule.next_level_type, self.rules), default=QualityType.EXCELLENT)

# TODO@nbirillo: why rule.quality_type == quality_type for next level????
# TODO: why rule.quality_type == quality_type for next level????
@property
def next_level_requirements(self) -> List[Rule]:
quality_type = self.quality_type
Expand Down
2 changes: 1 addition & 1 deletion src/python/review/quality/rules/cohesion_scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from src.python.review.common.language import Language
from src.python.review.inspectors.issue import IssueType
from src.python.review.quality.model import Rule, QualityType
from src.python.review.quality.model import QualityType, Rule


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion src/python/review/quality/rules/maintainability_scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from src.python.review.common.language import Language
from src.python.review.inspectors.issue import IssueType
from src.python.review.quality.model import Rule, QualityType
from src.python.review.quality.model import QualityType, Rule


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion src/python/review/reviewers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from src.python.review.inspectors.detekt.detekt import DetektInspector
from src.python.review.inspectors.eslint.eslint import ESLintInspector
from src.python.review.inspectors.flake8.flake8 import Flake8Inspector
from src.python.review.inspectors.radon.radon import RadonInspector
from src.python.review.inspectors.issue import BaseIssue
from src.python.review.inspectors.pmd.pmd import PMDInspector
from src.python.review.inspectors.pyast.python_ast import PythonAstInspector
from src.python.review.inspectors.pylint.pylint import PylintInspector
from src.python.review.inspectors.radon.radon import RadonInspector
from src.python.review.quality.evaluate_quality import evaluate_quality
from src.python.review.quality.model import Quality
from src.python.review.reviewers.review_result import FileReviewResult, ReviewResult
Expand Down
2 changes: 1 addition & 1 deletion src/python/review/reviewers/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import List

from src.python.review.application_config import ApplicationConfig
from src.python.review.common.file_system import get_all_file_system_items, FileSystemItem
from src.python.review.common.file_system import FileSystemItem, get_all_file_system_items
from src.python.review.common.language import Language
from src.python.review.reviewers.common import perform_language_review
from src.python.review.reviewers.review_result import ReviewResult
Expand Down
2 changes: 1 addition & 1 deletion src/python/review/reviewers/utils/code_statistics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from collections import Counter
from dataclasses import dataclass
from pathlib import Path
from typing import List, Dict
from typing import Dict, List

from src.python.review.common.file_system import get_content_from_file
from src.python.review.inspectors.issue import BaseIssue, IssueType
Expand Down
4 changes: 2 additions & 2 deletions src/python/review/reviewers/utils/issues_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
from src.python.review.inspectors.issue import BaseIssue, IssueType, Measurable
from src.python.review.quality.rules.boolean_length_scoring import LANGUAGE_TO_BOOLEAN_EXPRESSION_RULE_CONFIG
from src.python.review.quality.rules.class_response_scoring import LANGUAGE_TO_RESPONSE_RULE_CONFIG
from src.python.review.quality.rules.cohesion_scoring import LANGUAGE_TO_COHESION_RULE_CONFIG
from src.python.review.quality.rules.coupling_scoring import LANGUAGE_TO_COUPLING_RULE_CONFIG
from src.python.review.quality.rules.cyclomatic_complexity_scoring import LANGUAGE_TO_CYCLOMATIC_COMPLEXITY_RULE_CONFIG
from src.python.review.quality.rules.function_length_scoring import LANGUAGE_TO_FUNCTION_LENGTH_RULE_CONFIG
from src.python.review.quality.rules.inheritance_depth_scoring import LANGUAGE_TO_INHERITANCE_DEPTH_RULE_CONFIG
from src.python.review.quality.rules.maintainability_scoring import LANGUAGE_TO_MAINTAINABILITY_RULE_CONFIG
from src.python.review.quality.rules.method_number_scoring import LANGUAGE_TO_METHOD_NUMBER_RULE_CONFIG
from src.python.review.quality.rules.weighted_methods_scoring import LANGUAGE_TO_WEIGHTED_METHODS_RULE_CONFIG
from src.python.review.quality.rules.cohesion_scoring import LANGUAGE_TO_COHESION_RULE_CONFIG
from src.python.review.quality.rules.maintainability_scoring import LANGUAGE_TO_MAINTAINABILITY_RULE_CONFIG


def __get_issue_type_to_low_measure_dict(language: Language) -> Dict[IssueType, int]:
Expand Down
3 changes: 1 addition & 2 deletions src/python/review/run_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
import traceback
from enum import Enum, unique
from pathlib import Path
from typing import Set, List
from typing import List, Set

sys.path.append('')
sys.path.append('../../..')

from src.python.review.application_config import ApplicationConfig, LanguageVersion
from src.python.review.inspectors.inspector_type import InspectorType
from src.python.review.logging_config import logging_config

from src.python.review.reviewers.perform_review import (
OutputFormat,
PathNotExists,
Expand Down
3 changes: 1 addition & 2 deletions test/python/functional_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from dataclasses import dataclass, field
from pathlib import Path
from test.python import TEST_DATA_FOLDER
from typing import List, Optional

import pytest

from src.python import MAIN_FOLDER
from test.python import TEST_DATA_FOLDER

DATA_PATH = TEST_DATA_FOLDER / 'functional_tests'

Expand Down
1 change: 0 additions & 1 deletion test/python/functional_tests/test_different_languages.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import subprocess

from test.python.functional_tests.conftest import DATA_PATH, LocalCommandBuilder


Expand Down
1 change: 0 additions & 1 deletion test/python/functional_tests/test_disable.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import subprocess

from test.python.functional_tests.conftest import DATA_PATH, LocalCommandBuilder


Expand Down
1 change: 0 additions & 1 deletion test/python/functional_tests/test_duplicates.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import re
import subprocess

from test.python.functional_tests.conftest import DATA_PATH, LocalCommandBuilder


Expand Down
1 change: 0 additions & 1 deletion test/python/functional_tests/test_exit_code.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import subprocess
from pathlib import Path

from test.python.functional_tests.conftest import DATA_PATH, LocalCommandBuilder


Expand Down
1 change: 0 additions & 1 deletion test/python/functional_tests/test_file_or_project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import subprocess

from test.python.functional_tests.conftest import DATA_PATH, LocalCommandBuilder


Expand Down
1 change: 0 additions & 1 deletion test/python/functional_tests/test_multi_file_project.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import subprocess

from test.python.functional_tests.conftest import DATA_PATH, LocalCommandBuilder

EXPECTED_JSON = {
Expand Down
Loading

0 comments on commit 3df4664

Please sign in to comment.