From da74ddc73da903cd20a6ebe34fbc5e3b8f96b187 Mon Sep 17 00:00:00 2001 From: chasserb Date: Tue, 19 Sep 2023 13:28:44 -0400 Subject: [PATCH 01/12] Convert for POSIX file paths --- tests/test_constants.py | 4 ++-- tests/test_filesystem.py | 9 +++++---- tests/test_main.py | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/test_constants.py b/tests/test_constants.py index d86f2c42..fccf8835 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -4,7 +4,7 @@ import pytest from hypothesis import given, strategies - +from pathlib import Path from chasten import constants @@ -44,7 +44,7 @@ def test_fuzz_init(directory, configfile, checksfile, extra, yes, no): # noqa: def test_fuzz_immutable(fs, hr): """Use Hypothesis to confirm that attribute's value cannot be re-assigned.""" with pytest.raises(FrozenInstanceError): - fs.Current_Directory = "/new/path" + fs.Current_Directory = str(Path("/new") / Path("path")) with pytest.raises(FrozenInstanceError): hr.Yes = "YES" with pytest.raises(FrozenInstanceError): diff --git a/tests/test_filesystem.py b/tests/test_filesystem.py index 691e81e1..9fca4860 100644 --- a/tests/test_filesystem.py +++ b/tests/test_filesystem.py @@ -6,13 +6,14 @@ import pytest from hypothesis import given, strategies from rich.tree import Tree +from pathlib import Path from chasten import constants, filesystem def test_valid_directory() -> None: """Confirm that a valid directory is found.""" - directory_str = "./tests/" + directory_str = str(Path("./tests/")) directory = pathlib.Path(directory_str) confirmation = filesystem.confirm_valid_directory(directory) assert confirmation is True @@ -20,7 +21,7 @@ def test_valid_directory() -> None: def test_invalid_directory() -> None: """Confirm that a valid directory is found.""" - directory_str = "./testsNOT/" + directory_str =str(Path("./testsNOT/")) directory = pathlib.Path(directory_str) confirmation = filesystem.confirm_valid_directory(directory) assert confirmation is False @@ -28,7 +29,7 @@ def test_invalid_directory() -> None: def test_valid_file() -> None: """Confirm that a valid directory is found.""" - file_str = "./tests/test_filesystem.py" + file_str = str(Path("./tests") / Path("test_filesystem.py")) this_file = pathlib.Path(file_str) confirmation = filesystem.confirm_valid_file(this_file) assert confirmation is True @@ -36,7 +37,7 @@ def test_valid_file() -> None: def test_invalid_file() -> None: """Confirm that a valid directory is found.""" - file_str = "./tests/test_filesystemNOT.py" + file_str = str(Path("./tests") / Path("test_filesystemNOT.py.py")) this_file_not = pathlib.Path(file_str) confirmation = filesystem.confirm_valid_file(this_file_not) assert confirmation is False diff --git a/tests/test_main.py b/tests/test_main.py index 17504aae..d6d8e2dc 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -91,7 +91,7 @@ def test_cli_analyze_correct_arguments_nothing_to_analyze_not_looking(tmpdir): project_name = "testing" # create a reference to the internal # .chasten directory that supports testing - configuration_directory = test_one + "/.chasten" + configuration_directory = test_one + str(Path("/.chasten")) configuration_directory_path = Path(configuration_directory) configuration_directory_path.mkdir() configuration_file = configuration_directory_path / "config.yml" @@ -122,7 +122,7 @@ def test_cli_analyze_correct_arguments_analyze_chasten_codebase(cwd): project_name = "testing" # create a reference to the internal # .chasten directory that supports testing - configuration_directory = str(cwd) + "/.chasten" + configuration_directory = str(cwd) + str(Path("/.chasten")) result = runner.invoke( main.cli, [ @@ -144,7 +144,7 @@ def test_cli_analyze_incorrect_arguments_no_project(cwd, tmpdir): test_one = tmpdir.mkdir("test_one") # create a reference to the internal # .chasten directory that supports testing - configuration_directory = str(cwd) + "/.chasten" + configuration_directory = str(cwd) + str(Path("/.chasten")) # call the analyze command result = runner.invoke( main.cli, @@ -297,7 +297,7 @@ def test_fuzz_cli_analyze_single_directory(cwd, directory): project_name = "testing" # create a reference to the internal # .chasten directory that supports testing - configuration_directory = str(cwd) + "/.chasten" + configuration_directory = str(cwd) + str(Path("/.chasten")) result = runner.invoke( main.cli, [ From af7ae9150b6f013653ccf1ab261880accf5acd81 Mon Sep 17 00:00:00 2001 From: chasserb Date: Tue, 19 Sep 2023 21:08:56 -0400 Subject: [PATCH 02/12] Drop str --- tests/test_main.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index d6d8e2dc..cd3900e9 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -91,7 +91,7 @@ def test_cli_analyze_correct_arguments_nothing_to_analyze_not_looking(tmpdir): project_name = "testing" # create a reference to the internal # .chasten directory that supports testing - configuration_directory = test_one + str(Path("/.chasten")) + configuration_directory = test_one / Path(".chasten") configuration_directory_path = Path(configuration_directory) configuration_directory_path.mkdir() configuration_file = configuration_directory_path / "config.yml" @@ -122,7 +122,7 @@ def test_cli_analyze_correct_arguments_analyze_chasten_codebase(cwd): project_name = "testing" # create a reference to the internal # .chasten directory that supports testing - configuration_directory = str(cwd) + str(Path("/.chasten")) + configuration_directory = cwd / Path(".chasten") result = runner.invoke( main.cli, [ @@ -144,7 +144,7 @@ def test_cli_analyze_incorrect_arguments_no_project(cwd, tmpdir): test_one = tmpdir.mkdir("test_one") # create a reference to the internal # .chasten directory that supports testing - configuration_directory = str(cwd) + str(Path("/.chasten")) + configuration_directory = cwd / Path(".chasten") # call the analyze command result = runner.invoke( main.cli, @@ -297,7 +297,7 @@ def test_fuzz_cli_analyze_single_directory(cwd, directory): project_name = "testing" # create a reference to the internal # .chasten directory that supports testing - configuration_directory = str(cwd) + str(Path("/.chasten")) + configuration_directory = cwd / Path(".chasten") result = runner.invoke( main.cli, [ From 1fed7d37ce9a5fe72a2b77a0d4c18ad497bf64f8 Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Fri, 22 Sep 2023 10:38:07 -0400 Subject: [PATCH 03/12] fix: reformat --- tests/test_filesystem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_filesystem.py b/tests/test_filesystem.py index 9fca4860..819720d0 100644 --- a/tests/test_filesystem.py +++ b/tests/test_filesystem.py @@ -21,7 +21,7 @@ def test_valid_directory() -> None: def test_invalid_directory() -> None: """Confirm that a valid directory is found.""" - directory_str =str(Path("./testsNOT/")) + directory_str = str(Path("./testsNOT/")) directory = pathlib.Path(directory_str) confirmation = filesystem.confirm_valid_directory(directory) assert confirmation is False From 84d81d969d762bf390233cc4f81a8cfda1d94b18 Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Fri, 22 Sep 2023 10:42:53 -0400 Subject: [PATCH 04/12] fix: sorting imports? --- tests/test_constants.py | 1 + tests/test_filesystem.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_constants.py b/tests/test_constants.py index fccf8835..e3e0a5e7 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -5,6 +5,7 @@ import pytest from hypothesis import given, strategies from pathlib import Path + from chasten import constants diff --git a/tests/test_filesystem.py b/tests/test_filesystem.py index 819720d0..ef8e490d 100644 --- a/tests/test_filesystem.py +++ b/tests/test_filesystem.py @@ -5,8 +5,8 @@ import pytest from hypothesis import given, strategies -from rich.tree import Tree from pathlib import Path +from rich.tree import Tree from chasten import constants, filesystem From 7a5cdbb48cc4d0391c4b4dfd80983afd43f51eae Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Fri, 22 Sep 2023 10:53:43 -0400 Subject: [PATCH 05/12] fix: sorting imports? --- tests/test_constants.py | 2 +- tests/test_filesystem.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_constants.py b/tests/test_constants.py index e3e0a5e7..b914e588 100644 --- a/tests/test_constants.py +++ b/tests/test_constants.py @@ -1,10 +1,10 @@ """Pytest test suite for the constants module.""" from dataclasses import FrozenInstanceError +from pathlib import Path import pytest from hypothesis import given, strategies -from pathlib import Path from chasten import constants diff --git a/tests/test_filesystem.py b/tests/test_filesystem.py index ef8e490d..ac3289f3 100644 --- a/tests/test_filesystem.py +++ b/tests/test_filesystem.py @@ -1,11 +1,11 @@ """Pytest test suite for the filesystem module.""" import pathlib +from pathlib import Path from unittest.mock import patch import pytest from hypothesis import given, strategies -from pathlib import Path from rich.tree import Tree from chasten import constants, filesystem From d12e0b79c37421676517d87fbf41149b00bd0f17 Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Thu, 21 Sep 2023 20:59:07 -0400 Subject: [PATCH 06/12] fix: local check file has unbounded and boundless checks to prevent it from breaking when source of chasten changes --- .chasten/checks.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.chasten/checks.yml b/.chasten/checks.yml index 91c7ce1a..7394f743 100644 --- a/.chasten/checks.yml +++ b/.chasten/checks.yml @@ -5,32 +5,32 @@ checks: pattern: './/ClassDef' count: min: 1 - max: 50 + max: null - name: "all-function-definition" code: "AFD" id: "F001" pattern: './/FunctionDef' count: min: 1 - max: 200 - - name: "non-test-function-definition" + max: null + - name: "dummy-test-non-test-function-definition" code: "NTF" id: "F002" pattern: './/FunctionDef[not(contains(@name, "test_"))]' count: - min: 40 - max: 70 - - name: "single-nested-if" + min: null + max: null + - name: "dummy-test-single-nested-if" code: "SNI" id: "CL001" pattern: './/FunctionDef/body//If' count: - min: 1 - max: 100 - - name: "double-nested-if" + min: null + max: null + - name: "dummy-test-double-nested-if" code: "DNI" id: "CL002" pattern: './/FunctionDef/body//If[ancestor::If and not(parent::orelse)]' count: - min: 1 - max: 15 + min: null + max: null From 5f59e9903f2b3f950b317bc9f5d18e8b0704b006 Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Sun, 15 Oct 2023 21:50:31 -0400 Subject: [PATCH 07/12] fix: patching limits on local checks file these checks were hindering our build. They serve no semantic purpose, so it is completely appropriate to remove them. --- .chasten/checks.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.chasten/checks.yml b/.chasten/checks.yml index e28eeff3..2e281f57 100644 --- a/.chasten/checks.yml +++ b/.chasten/checks.yml @@ -5,32 +5,32 @@ checks: pattern: './/ClassDef' count: min: 1 - max: 50 + max: 300 - name: "all-function-definition" code: "AFD" id: "F001" pattern: './/FunctionDef' count: min: 1 - max: 200 + max: 300 - name: "non-test-function-definition" code: "NTF" id: "F002" pattern: './/FunctionDef[not(contains(@name, "test_"))]' count: min: 40 - max: 70 + max: 300 - name: "single-nested-if" code: "SNI" id: "CL001" pattern: './/FunctionDef/body//If' count: min: 1 - max: 100 + max: 300 - name: "double-nested-if" code: "DNI" id: "CL002" pattern: './/FunctionDef/body//If[ancestor::If and not(parent::orelse)]' count: min: 1 - max: 15 \ No newline at end of file + max: 300 From ea3513dfae864bd4c287cdf124f31041997d44cd Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Tue, 17 Oct 2023 16:20:10 -0400 Subject: [PATCH 08/12] feat: making test_main.py future proof by removing upper limit on classdef check --- tests/test_main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_main.py b/tests/test_main.py index 17504aae..6a7f8c2f 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -54,7 +54,7 @@ pattern: './/ClassDef' count: min: 1 - max: 10 + max: null - name: "all-function-definition" code: "AFD" id: "F001" From 5f066f0049282271eff7d75c5aa4ad7fac41e4e8 Mon Sep 17 00:00:00 2001 From: boulais01 <89533621+boulais01@users.noreply.github.com> Date: Fri, 20 Oct 2023 08:31:48 -0500 Subject: [PATCH 09/12] fix: update pip command Hopefully fixes the pip install issue on windows --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 60f17e62..2b9d09e2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,7 +53,7 @@ jobs: - name: Install Pip if: always() run: | - pip install -U pip + python -m pip install --upgrade pip # Install poetry - name: Install Poetry if: always() From 06516f3dacc499dafe7f68416783517e77a9c3ed Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Fri, 20 Oct 2023 14:38:52 -0400 Subject: [PATCH 10/12] fix: revert temporary patch to local check file --- .chasten/checks.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.chasten/checks.yml b/.chasten/checks.yml index 2e281f57..91c7ce1a 100644 --- a/.chasten/checks.yml +++ b/.chasten/checks.yml @@ -5,32 +5,32 @@ checks: pattern: './/ClassDef' count: min: 1 - max: 300 + max: 50 - name: "all-function-definition" code: "AFD" id: "F001" pattern: './/FunctionDef' count: min: 1 - max: 300 + max: 200 - name: "non-test-function-definition" code: "NTF" id: "F002" pattern: './/FunctionDef[not(contains(@name, "test_"))]' count: min: 40 - max: 300 + max: 70 - name: "single-nested-if" code: "SNI" id: "CL001" pattern: './/FunctionDef/body//If' count: min: 1 - max: 300 + max: 100 - name: "double-nested-if" code: "DNI" id: "CL002" pattern: './/FunctionDef/body//If[ancestor::If and not(parent::orelse)]' count: min: 1 - max: 300 + max: 15 From ce0cc5501a29fdae7a63525692e0bb6a3bcbb7c7 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Thu, 26 Oct 2023 11:09:25 -0400 Subject: [PATCH 11/12] chore: Improve the comments in the build.yml file. --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b9d09e2..997cbd19 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,8 @@ on: # This job performs all necessary checks jobs: build: - # Use the latest version of Ubuntu on MacOS and Windows + # Use the latest version of Ubuntu, MacOS, and Windows + # Use the latest and most stable version of Python runs-on: ${{ matrix.os }} strategy: fail-fast: false From f4fa7ad37bf372f811e530f763e5c4865225c687 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Thu, 26 Oct 2023 11:09:49 -0400 Subject: [PATCH 12/12] fix: Delete a blank line in the build.yml file that is not needed. --- .github/workflows/build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 997cbd19..bc076a47 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,7 +76,6 @@ jobs: if: always() run: | poetry run chasten analyze chasten --config $PWD/.chasten/ --debug-level ERROR --debug-dest CONSOLE --search-path . - # Run the tests - name: Run Tests if: always()