From 9038ef605c4cb63c926a1348edf93cab0055f4ce Mon Sep 17 00:00:00 2001 From: KellerLiptrap <97915015+KellerLiptrap@users.noreply.github.com> Date: Thu, 21 Sep 2023 21:33:17 -0400 Subject: [PATCH 01/47] syslog documentation --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index a0f2d6c2..e95a3c58 100644 --- a/README.md +++ b/README.md @@ -275,6 +275,16 @@ create the tool's command-line arguments and options through a terminal user interface (TUI). To use TUI-based way to create a complete command-line for `chasten` you can type the command `chasten interact`. +## 📊Log +`Chasten` has a built-in System Log. While using chasten you can use the command `chasten log` in your terminal. The system log feature allows the user to see events and messages that are produced by `chasten`. In addition, the `chasten log` feature will assist in finding bugs and the events that led to the bug happening. + +```shell +💫 chasten: Analyze the AST of Python Source Code +🔗 GitHub: https://github.com/gkapfham/chasten +✨ Syslog server for receiving debugging information +``` + + ## 🤗 Learning - **Curious about the nodes that are available in a Python program's AST?** From da74ddc73da903cd20a6ebe34fbc5e3b8f96b187 Mon Sep 17 00:00:00 2001 From: chasserb Date: Tue, 19 Sep 2023 13:28:44 -0400 Subject: [PATCH 02/47] 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 03/47] 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 04/47] 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 05/47] 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 06/47] 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 07/47] 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 b8f27a19996877eccee2dde3c5b50af1498edc08 Mon Sep 17 00:00:00 2001 From: KellerLiptrap <97915015+KellerLiptrap@users.noreply.github.com> Date: Mon, 25 Sep 2023 09:09:28 -0400 Subject: [PATCH 08/47] syslog code segment --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e95a3c58..88636850 100644 --- a/README.md +++ b/README.md @@ -278,7 +278,7 @@ interface (TUI). To use TUI-based way to create a complete command-line for ## 📊Log `Chasten` has a built-in System Log. While using chasten you can use the command `chasten log` in your terminal. The system log feature allows the user to see events and messages that are produced by `chasten`. In addition, the `chasten log` feature will assist in finding bugs and the events that led to the bug happening. -```shell +``` 💫 chasten: Analyze the AST of Python Source Code 🔗 GitHub: https://github.com/gkapfham/chasten ✨ Syslog server for receiving debugging information From 70e7b80e756155fbbb09843da9313d07e6b8d6b5 Mon Sep 17 00:00:00 2001 From: Finley8 Date: Mon, 2 Oct 2023 16:29:44 -0400 Subject: [PATCH 09/47] update --- chasten-test | 1 + debuggingbook | 1 + fuzzingbook | 1 + 3 files changed, 3 insertions(+) create mode 160000 chasten-test create mode 160000 debuggingbook create mode 160000 fuzzingbook diff --git a/chasten-test b/chasten-test new file mode 160000 index 00000000..2d8478da --- /dev/null +++ b/chasten-test @@ -0,0 +1 @@ +Subproject commit 2d8478da0234a1425f5e767e0d1a69d17ec26aa4 diff --git a/debuggingbook b/debuggingbook new file mode 160000 index 00000000..b492ac6e --- /dev/null +++ b/debuggingbook @@ -0,0 +1 @@ +Subproject commit b492ac6e09367ce124f15593664a7b6bc9d7475c diff --git a/fuzzingbook b/fuzzingbook new file mode 160000 index 00000000..5cbdedd0 --- /dev/null +++ b/fuzzingbook @@ -0,0 +1 @@ +Subproject commit 5cbdedd02abee0aab9341afcf518b290217b8309 From b50d54d86289e385853a0547bfe63274a02ce0ed Mon Sep 17 00:00:00 2001 From: Finley8 Date: Mon, 2 Oct 2023 16:31:11 -0400 Subject: [PATCH 10/47] removing books --- debuggingbook | 1 - fuzzingbook | 1 - 2 files changed, 2 deletions(-) delete mode 160000 debuggingbook delete mode 160000 fuzzingbook diff --git a/debuggingbook b/debuggingbook deleted file mode 160000 index b492ac6e..00000000 --- a/debuggingbook +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b492ac6e09367ce124f15593664a7b6bc9d7475c diff --git a/fuzzingbook b/fuzzingbook deleted file mode 160000 index 5cbdedd0..00000000 --- a/fuzzingbook +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5cbdedd02abee0aab9341afcf518b290217b8309 From c69898feded600aabd211c5eda556680a7bea61d Mon Sep 17 00:00:00 2001 From: VitalJoseph Date: Mon, 2 Oct 2023 16:40:58 -0400 Subject: [PATCH 11/47] added first implementation of xpath command line option --- chasten/main.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chasten/main.py b/chasten/main.py index 7f5cbae6..35b41542 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -384,6 +384,11 @@ def configure( # noqa: PLR0913 @cli.command() def analyze( # noqa: PLR0913, PLR0915 project: str = typer.Argument(help="Name of the project."), + xpath: str = typer.Option( + None, + "--xpath", + help="Version of xpath specified by user. (1.0 or 2.0)", + ), check_include: Tuple[enumerations.FilterableAttribute, str, int] = typer.Option( (None, None, 0), "--check-include", From 2767ffa31d9e40e4358c99f2e5a9bb461a49206a Mon Sep 17 00:00:00 2001 From: VitalJoseph Date: Mon, 2 Oct 2023 19:37:12 -0400 Subject: [PATCH 12/47] added condition --- chasten/main.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index 35b41542..bedc21ee 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -385,9 +385,9 @@ def configure( # noqa: PLR0913 def analyze( # noqa: PLR0913, PLR0915 project: str = typer.Argument(help="Name of the project."), xpath: str = typer.Option( - None, + "2.0", "--xpath", - help="Version of xpath specified by user. (1.0 or 2.0)", + help="Version of xpath specified by user. (1.0 or 2.0).", ), check_include: Tuple[enumerations.FilterableAttribute, str, int] = typer.Option( (None, None, 0), @@ -547,9 +547,12 @@ def analyze( # noqa: PLR0913, PLR0915 # search for the XML contents of an AST that match the provided # XPATH query using the search_python_file in search module of pyastgrep; # this looks for matches across all path(s) in the specified source path - match_generator = pyastgrepsearch.search_python_files( - paths=valid_directories, expression=current_xpath_pattern, xpath2=True - ) + + if xpath == "1.0": + match_generator = pyastgrepsearch.search_python_files(paths=valid_directories, expression=current_xpath_pattern, xpath2=False) + else: + match_generator = pyastgrepsearch.search_python_files(paths=valid_directories, expression=current_xpath_pattern, xpath2=True) + # materialize a list from the generator of (potential) matches; # note that this list will also contain an object that will # indicate that the analysis completed for each located file From 976e54b5b0d1f1ba16589af7c153c5954cf4d507 Mon Sep 17 00:00:00 2001 From: Keven Duverglas Date: Mon, 2 Oct 2023 20:14:23 -0400 Subject: [PATCH 13/47] Adding the command-line --- chasten-configuration | 1 + chasten/main.py | 11 ++++++----- multicounter | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) create mode 160000 chasten-configuration create mode 160000 multicounter diff --git a/chasten-configuration b/chasten-configuration new file mode 160000 index 00000000..e9d9bf47 --- /dev/null +++ b/chasten-configuration @@ -0,0 +1 @@ +Subproject commit e9d9bf476af50f36d5affe8d966bb8ab6b8ff3ab diff --git a/chasten/main.py b/chasten/main.py index bedc21ee..f24386e1 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -384,11 +384,6 @@ def configure( # noqa: PLR0913 @cli.command() def analyze( # noqa: PLR0913, PLR0915 project: str = typer.Argument(help="Name of the project."), - xpath: str = typer.Option( - "2.0", - "--xpath", - help="Version of xpath specified by user. (1.0 or 2.0).", - ), check_include: Tuple[enumerations.FilterableAttribute, str, int] = typer.Option( (None, None, 0), "--check-include", @@ -401,6 +396,12 @@ def analyze( # noqa: PLR0913, PLR0915 "-e", help="Attribute name, value, and match confidence level for exclusion.", ), + xpath: Tuple[enumerations.FilterableAttribute, str, int] = typer.Option( + (None, None, 0), + "--xpath", + "-a", + help="Runs the xpath version chosen.", + ), input_path: Path = typer.Option( filesystem.get_default_directory_list(), "--search-path", diff --git a/multicounter b/multicounter new file mode 160000 index 00000000..be3c47d9 --- /dev/null +++ b/multicounter @@ -0,0 +1 @@ +Subproject commit be3c47d906c641b347a4d2312b0aeecc50ad55ad From 86c7cef181f3f0f804d1758570d57f1931a97ae0 Mon Sep 17 00:00:00 2001 From: KellerLiptrap <97915015+KellerLiptrap@users.noreply.github.com> Date: Wed, 4 Oct 2023 09:43:24 -0400 Subject: [PATCH 14/47] added to syslog doc --- README.md | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 88636850..d81d73d5 100644 --- a/README.md +++ b/README.md @@ -276,15 +276,37 @@ interface (TUI). To use TUI-based way to create a complete command-line for `chasten` you can type the command `chasten interact`. ## 📊Log -`Chasten` has a built-in System Log. While using chasten you can use the command `chasten log` in your terminal. The system log feature allows the user to see events and messages that are produced by `chasten`. In addition, the `chasten log` feature will assist in finding bugs and the events that led to the bug happening. +`Chasten` has a built-in System Log. While using chasten you can use the command `chasten log` in your terminal. The system log feature allows the user to see events and messages that are produced by `chasten`. In addition, the `chasten log` feature will assist in finding bugs and the events that led to the bug happening. For the `chasten` program to display to the system log you will have to open a separate terminal and use the command `chasten log`. In addtion for each command that is run the `--debug-level ` and `--debug-dest SYSLOG` will need to be added. + +For example `chasten datasette-serve --debug-level DEBUG --debug-dest SYSLOG +< database path to file>` with produce the following output in the system log. ``` 💫 chasten: Analyze the AST of Python Source Code 🔗 GitHub: https://github.com/gkapfham/chasten ✨ Syslog server for receiving debugging information + +Display verbose output? False +Debug level? DEBUG +Debug destination? SYSLOG +``` + +In each command in `chasten`, there is an option to add `--debug-level`. The debug level has 5 options debug, info, warning, error, and critical. Each level will show different issues in the system log where debug is the lowest level of issue from the input where critical is the highest level of error. To leverage more info on this you can reference `debug.py` file below: + +``` +class DebugLevel(str, Enum): + """The predefined levels for debugging.""" + + DEBUG = "DEBUG" + INFO = "INFO" + WARNING = "WARNING" + ERROR = "ERROR" + CRITICAL = "CRITICAL" ``` + + ## 🤗 Learning - **Curious about the nodes that are available in a Python program's AST?** From 8e6f4a7e1bedb9c682db4e05b4cc7fefd8dbfa3f Mon Sep 17 00:00:00 2001 From: KellerLiptrap <97915015+KellerLiptrap@users.noreply.github.com> Date: Wed, 4 Oct 2023 09:44:21 -0400 Subject: [PATCH 15/47] changed wording --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d81d73d5..8961f125 100644 --- a/README.md +++ b/README.md @@ -291,9 +291,9 @@ Debug level? DEBUG Debug destination? SYSLOG ``` -In each command in `chasten`, there is an option to add `--debug-level`. The debug level has 5 options debug, info, warning, error, and critical. Each level will show different issues in the system log where debug is the lowest level of issue from the input where critical is the highest level of error. To leverage more info on this you can reference `debug.py` file below: +In each command in `chasten`, there is an option to add `--debug-level`. The debug level has 5 options debug, info, warning, error, and critical. Each level will show different issues in the system log where debug is the lowest level of issue from the input where critical is the highest level of error. To leverage more info on this you can reference `debug.py` file: -``` +``` python class DebugLevel(str, Enum): """The predefined levels for debugging.""" From 5f59e9903f2b3f950b317bc9f5d18e8b0704b006 Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Sun, 15 Oct 2023 21:50:31 -0400 Subject: [PATCH 16/47] 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 5671f345fbdb3540a36cf7b8163f46a0340ff326 Mon Sep 17 00:00:00 2001 From: Keven Michel Duverglas <112563981+KevenDuverglas@users.noreply.github.com> Date: Mon, 16 Oct 2023 09:09:30 -0400 Subject: [PATCH 17/47] Change the --xpath command option --- chasten/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index f24386e1..1418629c 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -396,11 +396,11 @@ def analyze( # noqa: PLR0913, PLR0915 "-e", help="Attribute name, value, and match confidence level for exclusion.", ), - xpath: Tuple[enumerations.FilterableAttribute, str, int] = typer.Option( - (None, None, 0), - "--xpath", - "-a", - help="Runs the xpath version chosen.", + xpath: Path = typer.Option( + str, + "--xpath-version", + "-xp", + help="Accepts different xpath version, runs xpath version two by default.", ), input_path: Path = typer.Option( filesystem.get_default_directory_list(), From 5dbf74e48a1e225404249301820038d9db118683 Mon Sep 17 00:00:00 2001 From: Finley8 Date: Mon, 16 Oct 2023 17:53:51 -0400 Subject: [PATCH 18/47] update --- chasten/__init__.py => __init__.py | 0 astute_subjects/chasten-configuration | 1 + astute_subjects/subject_forks/multicounter | 1 + chasten/main.py | 13 +++++++------ 4 files changed, 9 insertions(+), 6 deletions(-) rename chasten/__init__.py => __init__.py (100%) create mode 160000 astute_subjects/chasten-configuration create mode 160000 astute_subjects/subject_forks/multicounter diff --git a/chasten/__init__.py b/__init__.py similarity index 100% rename from chasten/__init__.py rename to __init__.py diff --git a/astute_subjects/chasten-configuration b/astute_subjects/chasten-configuration new file mode 160000 index 00000000..e9d9bf47 --- /dev/null +++ b/astute_subjects/chasten-configuration @@ -0,0 +1 @@ +Subproject commit e9d9bf476af50f36d5affe8d966bb8ab6b8ff3ab diff --git a/astute_subjects/subject_forks/multicounter b/astute_subjects/subject_forks/multicounter new file mode 160000 index 00000000..be3c47d9 --- /dev/null +++ b/astute_subjects/subject_forks/multicounter @@ -0,0 +1 @@ +Subproject commit be3c47d906c641b347a4d2312b0aeecc50ad55ad diff --git a/chasten/main.py b/chasten/main.py index bedc21ee..450550cd 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -383,12 +383,7 @@ def configure( # noqa: PLR0913 @cli.command() def analyze( # noqa: PLR0913, PLR0915 - project: str = typer.Argument(help="Name of the project."), - xpath: str = typer.Option( - "2.0", - "--xpath", - help="Version of xpath specified by user. (1.0 or 2.0).", - ), + project: str = typer.Argument(help="Name of the project."), check_include: Tuple[enumerations.FilterableAttribute, str, int] = typer.Option( (None, None, 0), "--check-include", @@ -401,6 +396,12 @@ def analyze( # noqa: PLR0913, PLR0915 "-e", help="Attribute name, value, and match confidence level for exclusion.", ), + xpath: Tuple[enumerations.FilterableAttribute, str, int] = typer.Option( + (None, None, 0), + "--xpath", + "-a", + help="Version of xpath specified by user. (1.0 or 2.0).", + ), input_path: Path = typer.Option( filesystem.get_default_directory_list(), "--search-path", From 6f0430f56852b600f16194037c7c12cd61c66590 Mon Sep 17 00:00:00 2001 From: Finley8 Date: Mon, 16 Oct 2023 18:31:07 -0400 Subject: [PATCH 19/47] Fix --- chasten/main.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index 114e6e01..e4c45380 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -385,10 +385,11 @@ def configure( # noqa: PLR0913 @cli.command() def analyze( # noqa: PLR0913, PLR0915 project: str = typer.Argument(help="Name of the project."), - xpath: str = typer.Option( - "2.0", - "--xpath", - help="Version of xpath specified by user. (1.0 or 2.0).", + xpath: Path = typer.Option( + str, + "--xpath-version", + "-xp", + help="Accepts different xpath version, runs xpath version two by default.", ), check_include: Tuple[enumerations.FilterableAttribute, str, int] = typer.Option( (None, None, 0), @@ -447,7 +448,7 @@ def analyze( # noqa: PLR0913, PLR0915 save: bool = typer.Option(False, help="Enable saving of output file(s)."), ) -> None: """💫 Analyze the AST of Python source code.""" - start_time = time.time + start_time = time.time() # output the preamble, including extra parameters specific to this function output_preamble( verbose, @@ -678,8 +679,9 @@ def analyze( # noqa: PLR0913, PLR0915 # confirm whether or not all of the checks passed # and then display the appropriate diagnostic message all_checks_passed = all(check_status_list) - end_time = time.time + end_time = time.time() elapsed_time = end_time - start_time + if not all_checks_passed: output.console.print("\n:sweat: At least one check did not pass.") sys.exit(constants.markers.Non_Zero_Exit) From dbdfb2df4343298b710250bf3cc8238677c60285 Mon Sep 17 00:00:00 2001 From: Finley8 Date: Mon, 16 Oct 2023 18:42:26 -0400 Subject: [PATCH 20/47] remove multicounter --- astute_subjects/chasten-configuration | 1 - astute_subjects/subject_forks/multicounter | 1 - multicounter | 1 - 3 files changed, 3 deletions(-) delete mode 160000 astute_subjects/chasten-configuration delete mode 160000 astute_subjects/subject_forks/multicounter delete mode 160000 multicounter diff --git a/astute_subjects/chasten-configuration b/astute_subjects/chasten-configuration deleted file mode 160000 index e9d9bf47..00000000 --- a/astute_subjects/chasten-configuration +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e9d9bf476af50f36d5affe8d966bb8ab6b8ff3ab diff --git a/astute_subjects/subject_forks/multicounter b/astute_subjects/subject_forks/multicounter deleted file mode 160000 index be3c47d9..00000000 --- a/astute_subjects/subject_forks/multicounter +++ /dev/null @@ -1 +0,0 @@ -Subproject commit be3c47d906c641b347a4d2312b0aeecc50ad55ad diff --git a/multicounter b/multicounter deleted file mode 160000 index be3c47d9..00000000 --- a/multicounter +++ /dev/null @@ -1 +0,0 @@ -Subproject commit be3c47d906c641b347a4d2312b0aeecc50ad55ad From 52093f4677d8b4c757068bd2c97f5fa8e02f2932 Mon Sep 17 00:00:00 2001 From: Finley8 Date: Tue, 17 Oct 2023 15:17:01 -0400 Subject: [PATCH 21/47] fix pip build --- chasten-configuration | 1 - 1 file changed, 1 deletion(-) delete mode 160000 chasten-configuration diff --git a/chasten-configuration b/chasten-configuration deleted file mode 160000 index e9d9bf47..00000000 --- a/chasten-configuration +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e9d9bf476af50f36d5affe8d966bb8ab6b8ff3ab From ea3513dfae864bd4c287cdf124f31041997d44cd Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Tue, 17 Oct 2023 16:20:10 -0400 Subject: [PATCH 22/47] 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 23/47] 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 8ddb9866f0be57a704a287dbff65658eedcc4d45 Mon Sep 17 00:00:00 2001 From: VitalJoseph Date: Fri, 20 Oct 2023 09:50:31 -0400 Subject: [PATCH 24/47] reformmated main --- chasten/main.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index e4c45380..398ca2cb 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -390,7 +390,7 @@ def analyze( # noqa: PLR0913, PLR0915 "--xpath-version", "-xp", help="Accepts different xpath version, runs xpath version two by default.", - ), + ), check_include: Tuple[enumerations.FilterableAttribute, str, int] = typer.Option( (None, None, 0), "--check-include", @@ -552,9 +552,13 @@ def analyze( # noqa: PLR0913, PLR0915 # this looks for matches across all path(s) in the specified source path if xpath == "1.0": - match_generator = pyastgrepsearch.search_python_files(paths=valid_directories, expression=current_xpath_pattern, xpath2=False) + match_generator = pyastgrepsearch.search_python_files( + paths=valid_directories, expression=current_xpath_pattern, xpath2=False + ) else: - match_generator = pyastgrepsearch.search_python_files(paths=valid_directories, expression=current_xpath_pattern, xpath2=True) + match_generator = pyastgrepsearch.search_python_files( + paths=valid_directories, expression=current_xpath_pattern, xpath2=True + ) # materialize a list from the generator of (potential) matches; # note that this list will also contain an object that will @@ -685,7 +689,9 @@ def analyze( # noqa: PLR0913, PLR0915 if not all_checks_passed: output.console.print("\n:sweat: At least one check did not pass.") sys.exit(constants.markers.Non_Zero_Exit) - output.console.print(f"\n:joy: All checks passed. Elapsed Time: {elapsed_time} seconds") + output.console.print( + f"\n:joy: All checks passed. Elapsed Time: {elapsed_time} seconds" + ) @cli.command() From 06516f3dacc499dafe7f68416783517e77a9c3ed Mon Sep 17 00:00:00 2001 From: Simon Jones Date: Fri, 20 Oct 2023 14:38:52 -0400 Subject: [PATCH 25/47] 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 26/47] 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 27/47] 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() From ea6b5c526259fb32b64a33b8f7670d4490ba46d6 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Thu, 26 Oct 2023 11:16:16 -0400 Subject: [PATCH 28/47] fix: Correct incorrectly indented comment in the build.yml file. --- .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 bc076a47..2027b339 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,7 +71,7 @@ jobs: if: always() run: | poetry run task lint - # Run the program + # Run the program - name: Run program if: always() run: | From bd79fb5218cf1499d240f2775b76fd582bed96ce Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Thu, 26 Oct 2023 11:28:34 -0400 Subject: [PATCH 29/47] chore: Add an explanatory comment to the top of the build.yml file. --- .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 2027b339..bd5bf436 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ on: branches: [ master ] # Create one single job -# This job performs all necessary checks +# This job performs all of the necessary checks jobs: build: # Use the latest version of Ubuntu, MacOS, and Windows From 0faa226c4613af49cab91a9053b674ff336b4f41 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Thu, 26 Oct 2023 11:31:11 -0400 Subject: [PATCH 30/47] chore: Add more explanatory comments to the build.yml file. --- .github/workflows/build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bd5bf436..ccbae035 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,6 +21,13 @@ jobs: build: # Use the latest version of Ubuntu, MacOS, and Windows # Use the latest and most stable version of Python + # Important: test coverage monitoring and reporting + # through a badge and the GitHub Actions job summary + # only takes place with the Linux operating system. + # Important: the MacOS and Windows operating systems + # have test coverage calculation take place but they + # do not report the test coverage beyond its display + # inside of the GitHub Actions panel for that job. runs-on: ${{ matrix.os }} strategy: fail-fast: false From 0a901927031d760d2300c3ca71ef9e1d04f37f61 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Thu, 26 Oct 2023 11:59:18 -0400 Subject: [PATCH 31/47] chore: Modify the way that test coverage is calculated and reported in build.yml. --- .github/workflows/build.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ccbae035..b28ea4d0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -88,13 +88,15 @@ jobs: if: always() run: | poetry run task test - # Run the test coverage monitoring - - name: Run Test Coverage - if: always() + # Run and collect the test coverage + # Important: only run and collect test coverage monitoring on Linux + - name: Run and Collect Test Coverage + if: always() && matrix.os == 'ubuntu-latest' run: | poetry run task test-coverage-silent > coverage.txt # Display the Coverage Report - - name: Display Coverage + # Important: only report the monitored test coverage on Linux + - name: Display Collected Test Coverage if: always() && matrix.os == 'ubuntu-latest' run: | export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") @@ -102,3 +104,13 @@ jobs: echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY CURRENT_GITHUB_STEP_SUMMARY="\`\`\`\n$(cat coverage.txt)\n\`\`\`" echo "$CURRENT_GITHUB_STEP_SUMMARY" >> $GITHUB_STEP_SUMMARY + # Run and display the test coverage + # If the current operating system is not Linux, then only run test + # coverage monitoring and display it inside of the GitHub Actions + # panel. This allows for test coverage to be calculated for each + # operating system. However, coverage is only reported for Linux + # through the badge and through the GitHub job summary. + - name: Run and Report Test Coverage + if: always() && matrix.os != 'ubuntu-latest' + run: | + poetry run task test-coverage From 4e574fbeefb400b2e99d7d5122fcd9e6e9e9f344 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Thu, 26 Oct 2023 12:04:51 -0400 Subject: [PATCH 32/47] chore: Improve the names of tasks in the build.yml file. --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b28ea4d0..62f607be 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -90,13 +90,13 @@ jobs: poetry run task test # Run and collect the test coverage # Important: only run and collect test coverage monitoring on Linux - - name: Run and Collect Test Coverage + - name: Run and Collect Test Coverage - Linux Only if: always() && matrix.os == 'ubuntu-latest' run: | poetry run task test-coverage-silent > coverage.txt # Display the Coverage Report # Important: only report the monitored test coverage on Linux - - name: Display Collected Test Coverage + - name: Display Collected Test Coverage - Linux Only if: always() && matrix.os == 'ubuntu-latest' run: | export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])") @@ -110,7 +110,7 @@ jobs: # panel. This allows for test coverage to be calculated for each # operating system. However, coverage is only reported for Linux # through the badge and through the GitHub job summary. - - name: Run and Report Test Coverage + - name: Run and Report Test Coverage - MacOS and Windows Only if: always() && matrix.os != 'ubuntu-latest' run: | poetry run task test-coverage From da7caa123c48ab932db15e162dfdde6dd413dce7 Mon Sep 17 00:00:00 2001 From: Finley8 Date: Fri, 27 Oct 2023 09:09:37 -0400 Subject: [PATCH 33/47] build update --- chasten/main.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index e4c45380..398ca2cb 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -390,7 +390,7 @@ def analyze( # noqa: PLR0913, PLR0915 "--xpath-version", "-xp", help="Accepts different xpath version, runs xpath version two by default.", - ), + ), check_include: Tuple[enumerations.FilterableAttribute, str, int] = typer.Option( (None, None, 0), "--check-include", @@ -552,9 +552,13 @@ def analyze( # noqa: PLR0913, PLR0915 # this looks for matches across all path(s) in the specified source path if xpath == "1.0": - match_generator = pyastgrepsearch.search_python_files(paths=valid_directories, expression=current_xpath_pattern, xpath2=False) + match_generator = pyastgrepsearch.search_python_files( + paths=valid_directories, expression=current_xpath_pattern, xpath2=False + ) else: - match_generator = pyastgrepsearch.search_python_files(paths=valid_directories, expression=current_xpath_pattern, xpath2=True) + match_generator = pyastgrepsearch.search_python_files( + paths=valid_directories, expression=current_xpath_pattern, xpath2=True + ) # materialize a list from the generator of (potential) matches; # note that this list will also contain an object that will @@ -685,7 +689,9 @@ def analyze( # noqa: PLR0913, PLR0915 if not all_checks_passed: output.console.print("\n:sweat: At least one check did not pass.") sys.exit(constants.markers.Non_Zero_Exit) - output.console.print(f"\n:joy: All checks passed. Elapsed Time: {elapsed_time} seconds") + output.console.print( + f"\n:joy: All checks passed. Elapsed Time: {elapsed_time} seconds" + ) @cli.command() From f368cf98f8c5d361d6cb16ac835241cd34166e2a Mon Sep 17 00:00:00 2001 From: KellerLiptrap <97915015+KellerLiptrap@users.noreply.github.com> Date: Fri, 27 Oct 2023 09:25:16 -0400 Subject: [PATCH 34/47] fixed capitalization --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8961f125..338c0883 100644 --- a/README.md +++ b/README.md @@ -276,7 +276,7 @@ interface (TUI). To use TUI-based way to create a complete command-line for `chasten` you can type the command `chasten interact`. ## 📊Log -`Chasten` has a built-in System Log. While using chasten you can use the command `chasten log` in your terminal. The system log feature allows the user to see events and messages that are produced by `chasten`. In addition, the `chasten log` feature will assist in finding bugs and the events that led to the bug happening. For the `chasten` program to display to the system log you will have to open a separate terminal and use the command `chasten log`. In addtion for each command that is run the `--debug-level ` and `--debug-dest SYSLOG` will need to be added. +`Chasten` has a built-in system log. While using chasten you can use the command `chasten log` in your terminal. The system log feature allows the user to see events and messages that are produced by `chasten`. In addition, the `chasten log` feature will assist in finding bugs and the events that led to the bug happening. For the `chasten` program to display to the system log you will have to open a separate terminal and use the command `chasten log`. In addition for each command that is run the `--debug-level ` and `--debug-dest SYSLOG` will need to be added. For example `chasten datasette-serve --debug-level DEBUG --debug-dest SYSLOG < database path to file>` with produce the following output in the system log. @@ -291,7 +291,7 @@ Debug level? DEBUG Debug destination? SYSLOG ``` -In each command in `chasten`, there is an option to add `--debug-level`. The debug level has 5 options debug, info, warning, error, and critical. Each level will show different issues in the system log where debug is the lowest level of issue from the input where critical is the highest level of error. To leverage more info on this you can reference `debug.py` file: +In each command in `chasten`, there is an option to add a `--debug-level`. The debug level has 5 options debug, info, warning, error, and critical. Each level will show different issues in the system log where debug is the lowest level of issue from the input where critical is the highest level of error. To leverage more info on this you can reference `debug.py` file: ``` python class DebugLevel(str, Enum): From 1903c1800f02b772c95323b4c98ed5adef026b6b Mon Sep 17 00:00:00 2001 From: KevenDuverglas Date: Fri, 27 Oct 2023 09:51:15 -0400 Subject: [PATCH 35/47] _int_ --- __init__.py => chasten/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename __init__.py => chasten/__init__.py (100%) diff --git a/__init__.py b/chasten/__init__.py similarity index 100% rename from __init__.py rename to chasten/__init__.py From 07a793dfaff097c5066a9ddca3fc18346a9790e4 Mon Sep 17 00:00:00 2001 From: KevenDuverglas Date: Fri, 27 Oct 2023 11:15:10 -0400 Subject: [PATCH 36/47] linting fixes --- chasten/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chasten/main.py b/chasten/main.py index 47853de4..dc192e2e 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -1,9 +1,9 @@ """💫 Chasten checks the AST of a Python program.""" import sys +import time from pathlib import Path from typing import Any, Dict, List, Tuple, Union -import time import typer import yaml From 1f5c8e33ec434c81c076122292656c35c2591adb Mon Sep 17 00:00:00 2001 From: KevenDuverglas Date: Fri, 27 Oct 2023 11:26:50 -0400 Subject: [PATCH 37/47] Testing to see what is causing the py error --- chasten/main.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index dc192e2e..6bddabf7 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -551,14 +551,14 @@ def analyze( # noqa: PLR0913, PLR0915 # XPATH query using the search_python_file in search module of pyastgrep; # this looks for matches across all path(s) in the specified source path - if xpath == "1.0": - match_generator = pyastgrepsearch.search_python_files( - paths=valid_directories, expression=current_xpath_pattern, xpath2=False - ) - else: - match_generator = pyastgrepsearch.search_python_files( - paths=valid_directories, expression=current_xpath_pattern, xpath2=True - ) + #if xpath == "1.0": + # match_generator = pyastgrepsearch.search_python_files( + # paths=valid_directories, expression=current_xpath_pattern, xpath2=False + # ) + #else: + # match_generator = pyastgrepsearch.search_python_files( + # paths=valid_directories, expression=current_xpath_pattern, xpath2=True + # ) # materialize a list from the generator of (potential) matches; # note that this list will also contain an object that will From 36cdf1e8f21e00ed6293631b835999cfb3d2b447 Mon Sep 17 00:00:00 2001 From: KevenDuverglas Date: Fri, 27 Oct 2023 11:34:10 -0400 Subject: [PATCH 38/47] taking out the if statement --- chasten/main.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index 6bddabf7..3fe7c2ba 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -550,15 +550,17 @@ def analyze( # noqa: PLR0913, PLR0915 # search for the XML contents of an AST that match the provided # XPATH query using the search_python_file in search module of pyastgrep; # this looks for matches across all path(s) in the specified source path - - #if xpath == "1.0": - # match_generator = pyastgrepsearch.search_python_files( - # paths=valid_directories, expression=current_xpath_pattern, xpath2=False - # ) - #else: - # match_generator = pyastgrepsearch.search_python_files( - # paths=valid_directories, expression=current_xpath_pattern, xpath2=True - # ) + match_generator = pyastgrepsearch.search_python_files( + paths=valid_directories, expression=current_xpath_pattern, xpath2=True + ) + # if xpath == "1.0": + # match_generator = pyastgrepsearch.search_python_files( + # paths=valid_directories, expression=current_xpath_pattern, xpath2=False + # ) + # else: + # match_generator = pyastgrepsearch.search_python_files( + # paths=valid_directories, expression=current_xpath_pattern, xpath2=True + # ) # materialize a list from the generator of (potential) matches; # note that this list will also contain an object that will From 16c3c387306c5cff4cd29ca7b38be97b7a982835 Mon Sep 17 00:00:00 2001 From: KevenDuverglas Date: Fri, 27 Oct 2023 11:44:47 -0400 Subject: [PATCH 39/47] concluding fixes to lint error --- chasten/main.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/chasten/main.py b/chasten/main.py index 3fe7c2ba..cac59bf4 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -550,17 +550,17 @@ def analyze( # noqa: PLR0913, PLR0915 # search for the XML contents of an AST that match the provided # XPATH query using the search_python_file in search module of pyastgrep; # this looks for matches across all path(s) in the specified source path - match_generator = pyastgrepsearch.search_python_files( - paths=valid_directories, expression=current_xpath_pattern, xpath2=True - ) - # if xpath == "1.0": - # match_generator = pyastgrepsearch.search_python_files( - # paths=valid_directories, expression=current_xpath_pattern, xpath2=False - # ) - # else: - # match_generator = pyastgrepsearch.search_python_files( + # match_generator = pyastgrepsearch.search_python_files( # paths=valid_directories, expression=current_xpath_pattern, xpath2=True - # ) + # ) + if xpath == "1.0": + match_generator = pyastgrepsearch.search_python_files( + paths=valid_directories, expression=current_xpath_pattern, xpath2=False + ) + else: + match_generator = pyastgrepsearch.search_python_files( + paths=valid_directories, expression=current_xpath_pattern, xpath2=True + ) # materialize a list from the generator of (potential) matches; # note that this list will also contain an object that will From 6d3b18780a31b0ade193f6b1af4b061abc17bb67 Mon Sep 17 00:00:00 2001 From: boulais01 <89533621+boulais01@users.noreply.github.com> Date: Mon, 30 Oct 2023 08:42:48 -0500 Subject: [PATCH 40/47] fix: resolve typo and format --- README.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d23783e9..5aa49ee5 100644 --- a/README.md +++ b/README.md @@ -295,10 +295,17 @@ interface (TUI). To use TUI-based way to create a complete command-line for `chasten` you can type the command `chasten interact`. ## 📊Log -`Chasten` has a built-in system log. While using chasten you can use the command `chasten log` in your terminal. The system log feature allows the user to see events and messages that are produced by `chasten`. In addition, the `chasten log` feature will assist in finding bugs and the events that led to the bug happening. For the `chasten` program to display to the system log you will have to open a separate terminal and use the command `chasten log`. In addition for each command that is run the `--debug-level ` and `--debug-dest SYSLOG` will need to be added. - -For example `chasten datasette-serve --debug-level DEBUG --debug-dest SYSLOG -< database path to file>` with produce the following output in the system log. +`Chasten` has a built-in system log. While using chasten you can use the command +`chasten log` in your terminal. The system log feature allows the user to see +events and messages that are produced by `chasten`. In addition, the `chasten log` +feature will assist in finding bugs and the events that led to the bug happening. +For the `chasten` program to display to the system log you will have to open a +separate terminal and use the command `chasten log`. In addition for each command +that is run the `--debug-level ` and `--debug-dest SYSLOG` will +need to be added. + +For example, `chasten datasette-serve --debug-level DEBUG --debug-dest SYSLOG +< database path to file>` will produce the following output in the system log. ``` 💫 chasten: Analyze the AST of Python Source Code From fe4bf583c723957531a97abc2e3e07377a65aced Mon Sep 17 00:00:00 2001 From: Finley8 Date: Mon, 30 Oct 2023 10:47:35 -0400 Subject: [PATCH 41/47] test --- chasten-configuration | 1 + 1 file changed, 1 insertion(+) create mode 160000 chasten-configuration diff --git a/chasten-configuration b/chasten-configuration new file mode 160000 index 00000000..e9d9bf47 --- /dev/null +++ b/chasten-configuration @@ -0,0 +1 @@ +Subproject commit e9d9bf476af50f36d5affe8d966bb8ab6b8ff3ab From 36925eb94726c63fb2169a8b1f32bce877bca245 Mon Sep 17 00:00:00 2001 From: Finley8 Date: Mon, 30 Oct 2023 10:48:53 -0400 Subject: [PATCH 42/47] test --- chasten-configuration | 1 - 1 file changed, 1 deletion(-) delete mode 160000 chasten-configuration diff --git a/chasten-configuration b/chasten-configuration deleted file mode 160000 index e9d9bf47..00000000 --- a/chasten-configuration +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e9d9bf476af50f36d5affe8d966bb8ab6b8ff3ab From 0a7835d32d4a5c6938fafd7d302f6c8d3f6c9da2 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 31 Oct 2023 10:13:47 -0400 Subject: [PATCH 43/47] fix: Remove the calculation of test coverage on Windows and MacOS in build.yml. --- .github/workflows/build.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 62f607be..61bc194f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -104,13 +104,3 @@ jobs: echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY CURRENT_GITHUB_STEP_SUMMARY="\`\`\`\n$(cat coverage.txt)\n\`\`\`" echo "$CURRENT_GITHUB_STEP_SUMMARY" >> $GITHUB_STEP_SUMMARY - # Run and display the test coverage - # If the current operating system is not Linux, then only run test - # coverage monitoring and display it inside of the GitHub Actions - # panel. This allows for test coverage to be calculated for each - # operating system. However, coverage is only reported for Linux - # through the badge and through the GitHub job summary. - - name: Run and Report Test Coverage - MacOS and Windows Only - if: always() && matrix.os != 'ubuntu-latest' - run: | - poetry run task test-coverage From c47578a5bba759aabb58a4f127622ed4c035d541 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 31 Oct 2023 10:15:07 -0400 Subject: [PATCH 44/47] chore: Add the use of test coverage on macOS in the build.yml file. --- .github/workflows/build.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 61bc194f..be41b5de 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -104,3 +104,13 @@ jobs: echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY CURRENT_GITHUB_STEP_SUMMARY="\`\`\`\n$(cat coverage.txt)\n\`\`\`" echo "$CURRENT_GITHUB_STEP_SUMMARY" >> $GITHUB_STEP_SUMMARY + # Run and display the test coverage + # If the current operating system is not Linux, then only run test + # coverage monitoring and display it inside of the GitHub Actions + # panel. This allows for test coverage to be calculated for each + # operating system. However, coverage is only reported for Linux + # through the badge and through the GitHub job summary. + - name: Run and Report Test Coverage - MacOS and Windows Only + if: always() && matrix.os == 'macOS' + run: | + poetry run task test-coverage From 7ce8141a61d41b07ce9dbc13698439d9c426cdbb Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 31 Oct 2023 10:23:18 -0400 Subject: [PATCH 45/47] chore: Update comments and labels in the build.yml file. --- .github/workflows/build.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index be41b5de..f2dbb169 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -105,12 +105,14 @@ jobs: CURRENT_GITHUB_STEP_SUMMARY="\`\`\`\n$(cat coverage.txt)\n\`\`\`" echo "$CURRENT_GITHUB_STEP_SUMMARY" >> $GITHUB_STEP_SUMMARY # Run and display the test coverage - # If the current operating system is not Linux, then only run test + # If the current operating system is MacOS, then only run test # coverage monitoring and display it inside of the GitHub Actions # panel. This allows for test coverage to be calculated for each # operating system. However, coverage is only reported for Linux - # through the badge and through the GitHub job summary. - - name: Run and Report Test Coverage - MacOS and Windows Only + # through the badge and through the GitHub job summary. Do not + # run any test coverage monitoring in Windows because it seems + # to be much slower and cause hypothesis-based tests to fail. + - name: Run and Report Test Coverage - MacOS Only if: always() && matrix.os == 'macOS' run: | poetry run task test-coverage From 05a77b24e6b66f0a9dec81e28cb964f2e77adb04 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 31 Oct 2023 14:04:23 -0400 Subject: [PATCH 46/47] fix: Add a HealthCheck setting for an Hypothesis test in test_validate.py. --- tests/test_validate.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_validate.py b/tests/test_validate.py index dda4fe1d..87845f23 100644 --- a/tests/test_validate.py +++ b/tests/test_validate.py @@ -1,7 +1,7 @@ """Pytest test suite for the validate module.""" import pytest -from hypothesis import given, strategies +from hypothesis import HealthCheck, given, settings, strategies from hypothesis_jsonschema import from_schema from chasten.validate import JSON_SCHEMA_CONFIG, validate_configuration @@ -44,6 +44,7 @@ def test_validate_empty_config(config): @given(from_schema(JSON_SCHEMA_CONFIG)) +@settings(suppress_health_check=[HealthCheck.too_slow]) @pytest.mark.fuzz def test_integers(config): """Use Hypothesis and the JSON schema plugin to confirm validation works for all possible valid instances.""" From 375b6fff85555de84af87c5d77908e983f9b0548 Mon Sep 17 00:00:00 2001 From: Keven Michel Duverglas <112563981+KevenDuverglas@users.noreply.github.com> Date: Wed, 1 Nov 2023 09:08:42 -0400 Subject: [PATCH 47/47] adding # PLR0912 to code --- chasten/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chasten/main.py b/chasten/main.py index cac59bf4..722f18a2 100644 --- a/chasten/main.py +++ b/chasten/main.py @@ -383,7 +383,7 @@ def configure( # noqa: PLR0913 @cli.command() -def analyze( # noqa: PLR0913, PLR0915 +def analyze( # noqa: PLR0912, PLR0913, PLR0915 project: str = typer.Argument(help="Name of the project."), xpath: Path = typer.Option( str,