Skip to content

Commit

Permalink
[#39]: Fix Linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Oct 26, 2022
1 parent 73f2262 commit d2c9d88
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
use-isort: false
extra-pylint-options: "--rcfile=setup.cfg --max-line-length=120 --max-locals=25 --min-similarity-lines=10"
extra-mypy-options: "--ignore-missing-imports --show-error-codes"
extra-flake8-options: "--max-line-length=120 --ignore=E203"
extra-pycodestyle-options: "--max-line-length=120 --ignore=E203"
extra-flake8-options: "--max-line-length=120 --ignore=E203,E402"
extra-pycodestyle-options: "--max-line-length=120 --ignore=E203,E402"
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ disable=
import-error,
missing-module-docstring,
missing-function-docstring,
global-statement
global-statement,
wrong-import-position
4 changes: 2 additions & 2 deletions src/run_static_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
COMMENT_TITLE = os.getenv("INPUT_COMMENT_TITLE")
ONLY_PR_CHANGES = os.getenv("INPUT_REPORT_PR_CHANGES_ONLY").lower()
VERBOSE = os.getenv("INPUT_VERBOSE", "False").lower() == "true"
FILES_WITH_ISSUES = dict()
FILES_WITH_ISSUES = {}

# Max characters per comment - 65536
# Make some room for HTML tags and error message
Expand Down Expand Up @@ -88,7 +88,7 @@ def get_lines_changed_from_patch(patch):


def setup_changed_files():
files_changed = dict()
files_changed = {}

github = Github(GITHUB_TOKEN)
repo = github.get_repo(TARGET_REPO_NAME)
Expand Down
18 changes: 10 additions & 8 deletions test/test_static_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
try:
project_path = f"{os.sep}".join(os.path.abspath(__file__).split(os.sep)[:-2])
sys.path.append(project_path)
except Exception as e:
print(f"Can not add project path to system path! Exiting!\nERROR: {e}")
raise SystemExit(1)
except Exception as exception:
print(f"Can not add project path to system path! Exiting!\nERROR: {exception}")
raise SystemExit(1) from exception

os.environ["GITHUB_WORKSPACE"] = f"{project_path}/test/utils"
os.environ["INPUT_VERBOSE"] = "True"
Expand All @@ -18,7 +18,9 @@
from src import run_static_analysis


class TestStringMethods(unittest.TestCase):
class TestRunStaticAnalysis(unittest.TestCase):
"""Unit tests for run_static_analysis module"""

def test_create_comment_for_output(self):

cppcheck_content = [
Expand All @@ -41,13 +43,13 @@ def test_create_comment_for_output(self):
cppcheck_content, "/github/workspace", files_changed_in_pr, False
)

SHA = os.getenv("GITHUB_SHA")
REPO_NAME = os.getenv("INPUT_REPO")
sha = os.getenv("GITHUB_SHA")
repo_name = os.getenv("INPUT_REPO")
expected = (
f"\n\nhttps://github.com/{REPO_NAME}/blob/{SHA}/DummyFile.cpp#L8-L9 \n"
f"\n\nhttps://github.com/{repo_name}/blob/{sha}/DummyFile.cpp#L8-L9 \n"
f"```diff\n!Line: 8 - style: Error message\n``` \n <br>"
f"\n\n```diff\n!Line: 6 - note: Note message\n``` "
f"\n\n\nhttps://github.com/{REPO_NAME}/blob/{SHA}/DummyFile.cpp#L3-L8 \n"
f"\n\n\nhttps://github.com/{repo_name}/blob/{sha}/DummyFile.cpp#L3-L8 \n"
f"```diff\n!Line: 3 - style: Error message\n``` \n <br>\n"
)

Expand Down

0 comments on commit d2c9d88

Please sign in to comment.