From 6cdda9992d3ca621f07b0275aa2b4aa943813e7f Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 2 Jul 2019 16:22:59 -0400 Subject: [PATCH 01/19] Add the command to run radon in the lint.sh script (gives diagnostics). --- scripts/lint.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index 6838bf374..c519957da 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -16,11 +16,13 @@ else FILES=$(find . -type f -regextype posix-extended -regex '\./(gator|tests)/.*.py') fi +# lint all of the Python source code files FILES="$FILES *.py" declare -A LINTERS -LINTERS=( ["black"]="pipenv run black $CHECK $FILES" ["pylint"]="pipenv run pylint $FILES" ["flake8"]="pipenv run flake8 $FILES" ["bandit"]="pipenv run bandit -c bandit.yml $FILES" ["pydocstyle"]="pipenv run pydocstyle $FILES" ) +# define all of the linters to iteratively run +LINTERS=( ["black"]="pipenv run black $CHECK $FILES" ["pylint"]="pipenv run pylint $FILES" ["flake8"]="pipenv run flake8 $FILES" ["bandit"]="pipenv run bandit -c bandit.yml $FILES" ["radon"]="pipenv run radon mi $FILES" ["pydocstyle"]="pipenv run pydocstyle $FILES" ) for tool in "${!LINTERS[@]}"; do echo " -- Running $tool" From 640243a2f3e1b50ea908d6dbbd370bef29ba0dbf Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 2 Jul 2019 17:00:50 -0400 Subject: [PATCH 02/19] Add comments and radon and xenon to the lint.sh file. --- scripts/lint.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index c519957da..cd0ff657f 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -1,15 +1,21 @@ #!/bin/bash +# determine whether or not black code formatting +# will fail if code is not correctly formatted +# "--check" returns non-zero exit code if formatting needed +# otherwise, the black check is run for diagnostic purposes if [[ "$1" == "--check" ]]; then CHECK="--check" else CHECK="" fi +# assume that all of the linters passed and prove otherwise PASSED=true OS="$(uname)" +# collect the files on MacOS if [[ "$OS" == "Darwin" ]]; then FILES=$(find -E . -type f -regex '\./(gator|tests)/.*.py') else @@ -19,11 +25,14 @@ fi # lint all of the Python source code files FILES="$FILES *.py" -declare -A LINTERS +# xenon cannot accept a lists of files, so give paths instead +PATHS="gator tests" # define all of the linters to iteratively run -LINTERS=( ["black"]="pipenv run black $CHECK $FILES" ["pylint"]="pipenv run pylint $FILES" ["flake8"]="pipenv run flake8 $FILES" ["bandit"]="pipenv run bandit -c bandit.yml $FILES" ["radon"]="pipenv run radon mi $FILES" ["pydocstyle"]="pipenv run pydocstyle $FILES" ) +declare -A LINTERS +LINTERS=( ["black"]="pipenv run black $CHECK $FILES" ["pylint"]="pipenv run pylint $FILES" ["flake8"]="pipenv run flake8 $FILES" ["bandit"]="pipenv run bandit -c bandit.yml $FILES" ["radon"]="pipenv run radon mi $FILES" ["xenon"]="xenon --max-absolute D --max-modules B --max-average B -c $PATHS" ["pydocstyle"]="pipenv run pydocstyle $FILES" ) +# run each of the already configured linters for tool in "${!LINTERS[@]}"; do echo " -- Running $tool" # shellcheck disable=SC2086 @@ -36,6 +45,7 @@ for tool in "${!LINTERS[@]}"; do echo "" done +# display the final diagnostic information if [[ "$PASSED" != "true" ]]; then echo "Not all linters passed!" exit 1 From 1676c98339f20c19920b5dfd48b4fa0ab6153f85 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 2 Jul 2019 17:04:52 -0400 Subject: [PATCH 03/19] Add comments about the linters to the lint.sh script. --- scripts/lint.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/lint.sh b/scripts/lint.sh index cd0ff657f..95025b2bc 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -28,6 +28,13 @@ FILES="$FILES *.py" # xenon cannot accept a lists of files, so give paths instead PATHS="gator tests" +# Notes about the linters: +# - black checks and fixes Python code formatting +# - pylint and flake8 check Python code +# - bandit finds security problems in Python code +# - radon checks code quality for diagnostic purposes +# - xenon returns an error code for code quality thresholds + # define all of the linters to iteratively run declare -A LINTERS LINTERS=( ["black"]="pipenv run black $CHECK $FILES" ["pylint"]="pipenv run pylint $FILES" ["flake8"]="pipenv run flake8 $FILES" ["bandit"]="pipenv run bandit -c bandit.yml $FILES" ["radon"]="pipenv run radon mi $FILES" ["xenon"]="xenon --max-absolute D --max-modules B --max-average B -c $PATHS" ["pydocstyle"]="pipenv run pydocstyle $FILES" ) From f1108fdd0054c56bae62c8de49fe30763aabf012 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 2 Jul 2019 17:05:20 -0400 Subject: [PATCH 04/19] Update the Pipfile and the Pipfile.lock with radon and xenon. --- Pipfile | 2 + Pipfile.lock | 103 +++++++++++++++++++++++++++++++++------------------ 2 files changed, 68 insertions(+), 37 deletions(-) diff --git a/Pipfile b/Pipfile index 807290903..72210aa88 100644 --- a/Pipfile +++ b/Pipfile @@ -23,6 +23,8 @@ mutmut = "*" bandit = "*" codacy-coverage = "*" pydocstyle = "*" +radon = "*" +xenon = "*" [pipenv] allow_prereleases = true diff --git a/Pipfile.lock b/Pipfile.lock index f3a4a3790..3f6fa030d 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "52a7cb0882b92254ec8e74112fe905dd1b7153141995d10a89086364eb90b75e" + "sha256": "8f318cc064736af377be25959e9d3a1b4a2ced9913f23f7f5ce027c44798c904" }, "pipfile-spec": 6, "requires": {}, @@ -132,11 +132,11 @@ }, "bandit": { "hashes": [ - "sha256:f89adaff792d1f9b72859784c5f7964c6b5a5f32ca0ca458c9643e02d4fdceac", - "sha256:fa1fee3cb60a3dca89b7a86c0be82af0e830def961728aba9290854fe18c1f90" + "sha256:336620e220cf2d3115877685e264477ff9d9abaeb0afe3dc7264f55fa17a3952", + "sha256:41e75315853507aa145d62a78a2a6c5e3240fe14ee7c601459d0df9418196065" ], "index": "pypi", - "version": "==1.6.1" + "version": "==1.6.2" }, "black": { "hashes": [ @@ -183,6 +183,13 @@ "index": "pypi", "version": "==2.0.15" }, + "colorama": { + "hashes": [ + "sha256:463f8483208e921368c9f306094eb6f725c6ca42b0f97e313cb5d5512459feda", + "sha256:48eb22f4f8461b1df5734a074b57042430fb06e1d61bd1e11b078c0fe6d7a1f1" + ], + "version": "==0.3.9" + }, "coverage": { "hashes": [ "sha256:0402b1822d513d0231589494bceddb067d20581f5083598c451b56c684b0e5d6", @@ -230,6 +237,13 @@ "index": "pypi", "version": "==3.7.7" }, + "flake8-polyfill": { + "hashes": [ + "sha256:12be6a34ee3ab795b19ca73505e7b55826d5f6ad7230d31b18e106400169b9e9", + "sha256:e44b087597f6da52ec6393a709e7108b2905317d0c0b744cdca6208e670d8eda" + ], + "version": "==1.0.2" + }, "gitdb2": { "hashes": [ "sha256:83361131a1836661a155172932a13c08bda2db3674e4caa32368aa6eb02f38c2", @@ -291,10 +305,10 @@ }, "isort": { "hashes": [ - "sha256:c40744b6bc5162bbb39c1257fe298b7a393861d50978b565f3ccd9cb9de0182a", - "sha256:f57abacd059dc3bd666258d1efb0377510a89777fda3e3274e3c01f7c03ae22d" + "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1", + "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd" ], - "version": "==4.3.20" + "version": "==4.3.21" }, "junit-xml": { "hashes": [ @@ -325,6 +339,13 @@ ], "version": "==1.4.1" }, + "mando": { + "hashes": [ + "sha256:4ce09faec7e5192ffc3c57830e26acba0fd6cd11e1ee81af0d4df0657463bd1c", + "sha256:79feb19dc0f097daa64a1243db578e7674909b75f88ac2220f1c065c10a0d960" + ], + "version": "==0.6.4" + }, "mccabe": { "hashes": [ "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42", @@ -334,11 +355,10 @@ }, "more-itertools": { "hashes": [ - "sha256:2112d2ca570bb7c3e53ea1a35cd5df42bb0fd10c45f0fb97178679c3c03d64c7", - "sha256:c3e4748ba1aad8dba30a4886b0b1a2004f9a863837b8654e7059eebf727afa5a" + "sha256:3ad685ff8512bf6dc5a8b82ebf73543999b657eded8c11803d9ba6b648986f4d", + "sha256:8bb43d1f51ecef60d81854af61a3a880555a14643691cc4b64a6ee269c78f09a" ], - "markers": "python_version > '2.7'", - "version": "==7.0.0" + "version": "==7.1.0" }, "msgpack": { "hashes": [ @@ -385,17 +405,17 @@ }, "parso": { "hashes": [ - "sha256:17cc2d7a945eb42c3569d4564cdf49bde221bc2b552af3eca9c1aad517dcdd33", - "sha256:2e9574cb12e7112a87253e14e2c380ce312060269d04bd018478a3c92ea9a376" + "sha256:5052bb33be034cba784193e74b1cde6ebf29ae8b8c1e4ad94df0c4209bfc4826", + "sha256:db5881df1643bf3e66c097bfd8935cf03eae73f4cb61ae4433c9ea4fb6613446" ], - "version": "==0.4.0" + "version": "==0.5.0" }, "pbr": { "hashes": [ - "sha256:089ccb087e9bd8f278caedfa6c2c5d461381437eda3db750b6834e78b319f404", - "sha256:9fb1c3371344cd617eb073c6c00872e9b0e5a7fefed6cd29f327a1b26ab5c498" + "sha256:9181e2a34d80f07a359ff1d0504fad3a47e00e1cf2c475b0aa7dcb030af54c40", + "sha256:94bdc84da376b3dd5061aa0c3b6faffe943ee2e56fa4ff9bd63e1643932f34fc" ], - "version": "==5.3.0" + "version": "==5.3.1" }, "pluggy": { "hashes": [ @@ -463,11 +483,11 @@ }, "pytest": { "hashes": [ - "sha256:4a784f1d4f2ef198fe9b7aef793e9fa1a3b2f84e822d9b3a64a181293a572d45", - "sha256:926855726d8ae8371803f7b2e6ec0a69953d9c6311fa7c3b6c1b929ff92d27da" + "sha256:2878de8ae1c79a62c012da6186b88ff0562ea96ce29c4208d2a9b11d9f607df1", + "sha256:95b700cf21ed5b7e91bce7a6b5a573b2e3ef7b3643d00f681d8f9c4672f9fbdf" ], "index": "pypi", - "version": "==4.6.3" + "version": "==5.0.0" }, "pytest-cov": { "hashes": [ @@ -487,19 +507,21 @@ }, "pyyaml": { "hashes": [ - "sha256:57acc1d8533cbe51f6662a55434f0dbecfa2b9eaf115bede8f6fd00115a0c0d3", - "sha256:588c94b3d16b76cfed8e0be54932e5729cc185caffaa5a451e7ad2f7ed8b4043", - "sha256:68c8dd247f29f9a0d09375c9c6b8fdc64b60810ebf07ba4cdd64ceee3a58c7b7", - "sha256:70d9818f1c9cd5c48bb87804f2efc8692f1023dac7f1a1a5c61d454043c1d265", - "sha256:86a93cccd50f8c125286e637328ff4eef108400dd7089b46a7be3445eecfa391", - "sha256:a0f329125a926876f647c9fa0ef32801587a12328b4a3c741270464e3e4fa778", - "sha256:a3c252ab0fa1bb0d5a3f6449a4826732f3eb6c0270925548cac342bc9b22c225", - "sha256:b4bb4d3f5e232425e25dda21c070ce05168a786ac9eda43768ab7f3ac2770955", - "sha256:cd0618c5ba5bda5f4039b9398bb7fb6a317bb8298218c3de25c47c4740e4b95e", - "sha256:ceacb9e5f8474dcf45b940578591c7f3d960e82f926c707788a570b51ba59190", - "sha256:fe6a88094b64132c4bb3b631412e90032e8cfe9745a58370462240b8cb7553cd" + "sha256:254bf6fda2b7c651837acb2c718e213df29d531eebf00edb54743d10bcb694eb", + "sha256:3108529b78577327d15eec243f0ff348a0640b0c3478d67ad7f5648f93bac3e2", + "sha256:3c17fb92c8ba2f525e4b5f7941d850e7a48c3a59b32d331e2502a3cdc6648e76", + "sha256:8d6d96001aa7f0a6a4a95e8143225b5d06e41b1131044913fecb8f85a125714b", + "sha256:c8a88edd93ee29ede719080b2be6cb2333dfee1dccba213b422a9c8e97f2967b" ], - "version": "==5.1.1" + "version": "==4.2b4" + }, + "radon": { + "hashes": [ + "sha256:38e495a4aa4c1d7293d3c1733393961fb52209c9bc2d75163c3ba8124d8bbbaa", + "sha256:f893f2faa632a060f6d0f01843d10a0395515bde865c759c0dd3f15239caf11b" + ], + "index": "pypi", + "version": "==2.4.0" }, "requests": { "hashes": [ @@ -526,10 +548,9 @@ }, "snowballstemmer": { "hashes": [ - "sha256:919f26a68b2c17a7634da993d91339e288964f93c274f1343e3bbbe2096e1128", - "sha256:9f3bcd3c401c3e862ec0ebe6d2c069ebc012ce142cce209c098ccb5b09136e89" + "sha256:9f3b9ffe0809d174f7047e121431acf99c89a7040f0ca84f94ba53a498e6d0c9" ], - "version": "==1.2.1" + "version": "==1.9.0" }, "stevedore": { "hashes": [ @@ -553,9 +574,9 @@ }, "tri.declarative": { "hashes": [ - "sha256:17ab36d1f1326a1ff51a769de4e4acbec5a9c14bc9ba15b961fee62c411250a6" + "sha256:a70617f2fbfecce12e10beddba8db469ebe6aa6eebec86f2f2eca6fd9a6e83c3" ], - "version": "==3.0.0" + "version": "==3.1.0" }, "tri.struct": { "hashes": [ @@ -604,6 +625,14 @@ ], "version": "==1.11.2" }, + "xenon": { + "hashes": [ + "sha256:26f65adb5d411ba3efc361dc5ab6cd341a243a33b5a526c89350240c765899b9", + "sha256:ff4bbecf0da99a7f60033e5e9616e28eb2a52d78dc154d90736f8c0124ec3e76" + ], + "index": "pypi", + "version": "==0.5.5" + }, "zipp": { "hashes": [ "sha256:8c1019c6aad13642199fbe458275ad6a84907634cc9f0989877ccc4a2840139d", From 6e99e4f372ec052d7d45d6212f506ef7b5e05e80 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 2 Jul 2019 17:09:39 -0400 Subject: [PATCH 05/19] Add a missing "pipenv run" to the xenon command in lint.sh script. --- scripts/lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index 95025b2bc..3ca81a206 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -37,7 +37,7 @@ PATHS="gator tests" # define all of the linters to iteratively run declare -A LINTERS -LINTERS=( ["black"]="pipenv run black $CHECK $FILES" ["pylint"]="pipenv run pylint $FILES" ["flake8"]="pipenv run flake8 $FILES" ["bandit"]="pipenv run bandit -c bandit.yml $FILES" ["radon"]="pipenv run radon mi $FILES" ["xenon"]="xenon --max-absolute D --max-modules B --max-average B -c $PATHS" ["pydocstyle"]="pipenv run pydocstyle $FILES" ) +LINTERS=( ["black"]="pipenv run black $CHECK $FILES" ["pylint"]="pipenv run pylint $FILES" ["flake8"]="pipenv run flake8 $FILES" ["bandit"]="pipenv run bandit -c bandit.yml $FILES" ["radon"]="pipenv run radon mi $FILES" ["xenon"]="pipenv run xenon --max-absolute D --max-modules B --max-average B -c $PATHS" ["pydocstyle"]="pipenv run pydocstyle $FILES" ) # run each of the already configured linters for tool in "${!LINTERS[@]}"; do From feab22efb5b28120fc8ee51bd614242bca1b2726 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 2 Jul 2019 17:11:49 -0400 Subject: [PATCH 06/19] Add the integration with xenon and radon to the lint.bat file. --- scripts/lint.bat | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/scripts/lint.bat b/scripts/lint.bat index 9358e537e..7b4cda011 100644 --- a/scripts/lint.bat +++ b/scripts/lint.bat @@ -13,6 +13,8 @@ dir /b /s | findstr "\\*.py$" | findstr /v "\\\.venv\\" > .xyzfiles for /f "Tokens=* Delims=" %%x in (.xyzfiles) do set FILES=!FILES! %%x del .xyzfiles +set PATHS="gator tests" + echo -- Running black pipenv run black %CHECK% %FILES% if ERRORLEVEL 1 ( @@ -58,6 +60,24 @@ if ERRORLEVEL 1 ( echo -- Passed ) +echo -- Running radon +pipenv run radon mi %FILES% +if ERRORLEVEL 1 ( + echo -- Failed + set PASSED=false +) else ( + echo -- Passed +) + +echo -- Running xenon +pipenv run xenon --max-absolute D --max-modules B --max-average B -c %PATHS% +if ERRORLEVEL 1 ( + echo -- Failed + set PASSED=false +) else ( + echo -- Passed +) + if "%PASSED%"=="true" ( exit /b 0 ) else ( From 649f3b7dcf11f54b86e1478ac11861d8cffcb4d4 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 2 Jul 2019 17:22:06 -0400 Subject: [PATCH 07/19] Changed the value of the PATHS variable in the lint.bat file. --- scripts/lint.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lint.bat b/scripts/lint.bat index 7b4cda011..b9fa1a0e8 100644 --- a/scripts/lint.bat +++ b/scripts/lint.bat @@ -13,7 +13,7 @@ dir /b /s | findstr "\\*.py$" | findstr /v "\\\.venv\\" > .xyzfiles for /f "Tokens=* Delims=" %%x in (.xyzfiles) do set FILES=!FILES! %%x del .xyzfiles -set PATHS="gator tests" +set PATHS=gator tests echo -- Running black pipenv run black %CHECK% %FILES% From 55fd7438878973298a1f13920cfc8799513acb14 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 2 Jul 2019 17:43:25 -0400 Subject: [PATCH 08/19] Change the lint.bat file so that it runs xenon on gator directory. --- scripts/lint.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint.bat b/scripts/lint.bat index b9fa1a0e8..1dc68a07e 100644 --- a/scripts/lint.bat +++ b/scripts/lint.bat @@ -13,7 +13,7 @@ dir /b /s | findstr "\\*.py$" | findstr /v "\\\.venv\\" > .xyzfiles for /f "Tokens=* Delims=" %%x in (.xyzfiles) do set FILES=!FILES! %%x del .xyzfiles -set PATHS=gator tests +set GATOR=gator echo -- Running black pipenv run black %CHECK% %FILES% @@ -70,7 +70,7 @@ if ERRORLEVEL 1 ( ) echo -- Running xenon -pipenv run xenon --max-absolute D --max-modules B --max-average B -c %PATHS% +pipenv run xenon --max-absolute D --max-modules B --max-average B -c %GATOR% if ERRORLEVEL 1 ( echo -- Failed set PASSED=false From 0c735eaa296fda396b9f7ee73071c4c54ddbc84d Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 2 Jul 2019 17:55:15 -0400 Subject: [PATCH 09/19] Directly specify gator and tests in lint.bat for the xenon call. --- scripts/lint.bat | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/lint.bat b/scripts/lint.bat index 1dc68a07e..0d79fae0b 100644 --- a/scripts/lint.bat +++ b/scripts/lint.bat @@ -13,8 +13,6 @@ dir /b /s | findstr "\\*.py$" | findstr /v "\\\.venv\\" > .xyzfiles for /f "Tokens=* Delims=" %%x in (.xyzfiles) do set FILES=!FILES! %%x del .xyzfiles -set GATOR=gator - echo -- Running black pipenv run black %CHECK% %FILES% if ERRORLEVEL 1 ( @@ -70,7 +68,7 @@ if ERRORLEVEL 1 ( ) echo -- Running xenon -pipenv run xenon --max-absolute D --max-modules B --max-average B -c %GATOR% +pipenv run xenon --max-absolute D --max-modules B --max-average B -c gator tests if ERRORLEVEL 1 ( echo -- Failed set PASSED=false From 9838bbcb64aa38e12f49f76922b6aec145df4fe8 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 2 Jul 2019 17:59:27 -0400 Subject: [PATCH 10/19] Remove the call to xenon in the lint.bat file. --- scripts/lint.bat | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/lint.bat b/scripts/lint.bat index 0d79fae0b..da1789cc0 100644 --- a/scripts/lint.bat +++ b/scripts/lint.bat @@ -67,15 +67,6 @@ if ERRORLEVEL 1 ( echo -- Passed ) -echo -- Running xenon -pipenv run xenon --max-absolute D --max-modules B --max-average B -c gator tests -if ERRORLEVEL 1 ( - echo -- Failed - set PASSED=false -) else ( - echo -- Passed -) - if "%PASSED%"=="true" ( exit /b 0 ) else ( From 13c28c0895b926a59dc791a1d1b8a90367593e49 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Tue, 2 Jul 2019 18:16:59 -0400 Subject: [PATCH 11/19] Revert the lint.bat file back to version before radon and xenon. --- scripts/lint.bat | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/lint.bat b/scripts/lint.bat index da1789cc0..9358e537e 100644 --- a/scripts/lint.bat +++ b/scripts/lint.bat @@ -58,15 +58,6 @@ if ERRORLEVEL 1 ( echo -- Passed ) -echo -- Running radon -pipenv run radon mi %FILES% -if ERRORLEVEL 1 ( - echo -- Failed - set PASSED=false -) else ( - echo -- Passed -) - if "%PASSED%"=="true" ( exit /b 0 ) else ( From 4fe2b30fba822279af4f08e87361822a978f5ffb Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Sat, 6 Jul 2019 17:33:38 -0400 Subject: [PATCH 12/19] chore: Improve a comment in the lint.sh file. --- scripts/lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index 3ca81a206..d3dc92cdf 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -28,7 +28,7 @@ FILES="$FILES *.py" # xenon cannot accept a lists of files, so give paths instead PATHS="gator tests" -# Notes about the linters: +# Notes about the linters run on Linux and MacOS: # - black checks and fixes Python code formatting # - pylint and flake8 check Python code # - bandit finds security problems in Python code From d7141f6c70ec2fe2f366065707074b8944270e1c Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Sat, 6 Jul 2019 17:38:59 -0400 Subject: [PATCH 13/19] chore: Delete the use of bandit in the lint.bat file. --- scripts/lint.bat | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/lint.bat b/scripts/lint.bat index 9358e537e..a271cdd4b 100644 --- a/scripts/lint.bat +++ b/scripts/lint.bat @@ -40,15 +40,6 @@ if ERRORLEVEL 1 ( echo -- Passed ) -echo -- Running bandit -pipenv run bandit -c bandit.yml %FILES% -if ERRORLEVEL 1 ( - echo -- Failed - set PASSED=false -) else ( - echo -- Passed -) - echo -- Running pydocstyle pipenv run pydocstyle %FILES% if ERRORLEVEL 1 ( From aad353d42c8725bb4027e584ec199060595bc250 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Sat, 6 Jul 2019 18:07:16 -0400 Subject: [PATCH 14/19] chore: Run radon in two modes, improve comments in lint.sh. --- scripts/lint.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index d3dc92cdf..f4ad4b561 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -25,19 +25,22 @@ fi # lint all of the Python source code files FILES="$FILES *.py" -# xenon cannot accept a lists of files, so give paths instead -PATHS="gator tests" +# xenon cannot accept a lists of files or directories, +# so give the directory of the main module instead +MODULE="gator" # Notes about the linters run on Linux and MacOS: # - black checks and fixes Python code formatting # - pylint and flake8 check Python code # - bandit finds security problems in Python code # - radon checks code quality for diagnostic purposes +# --> cc is for calculating cyclomatic complexity +# --> mi is for calculating maintainability index # - xenon returns an error code for code quality thresholds # define all of the linters to iteratively run declare -A LINTERS -LINTERS=( ["black"]="pipenv run black $CHECK $FILES" ["pylint"]="pipenv run pylint $FILES" ["flake8"]="pipenv run flake8 $FILES" ["bandit"]="pipenv run bandit -c bandit.yml $FILES" ["radon"]="pipenv run radon mi $FILES" ["xenon"]="pipenv run xenon --max-absolute D --max-modules B --max-average B -c $PATHS" ["pydocstyle"]="pipenv run pydocstyle $FILES" ) +LINTERS=( ["black"]="pipenv run black $CHECK $FILES" ["pylint"]="pipenv run pylint $FILES" ["flake8"]="pipenv run flake8 $FILES" ["bandit"]="pipenv run bandit -c bandit.yml $FILES" ["radon-cc"]="pipenv run radon cc $FILES" ["radon-mi"]="pipenv run radon mi $FILES" ["xenon"]="pipenv run xenon --max-absolute D --max-modules B --max-average B $MODULE" ["pydocstyle"]="pipenv run pydocstyle $FILES" ) # run each of the already configured linters for tool in "${!LINTERS[@]}"; do From 54d029faaee6cd5d698f2948ba59d61f08699f63 Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Sat, 6 Jul 2019 18:09:56 -0400 Subject: [PATCH 15/19] chore: Change the xenon grades to D, B, A for abs, mod, avg. --- scripts/lint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index f4ad4b561..28c6b4193 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -40,7 +40,7 @@ MODULE="gator" # define all of the linters to iteratively run declare -A LINTERS -LINTERS=( ["black"]="pipenv run black $CHECK $FILES" ["pylint"]="pipenv run pylint $FILES" ["flake8"]="pipenv run flake8 $FILES" ["bandit"]="pipenv run bandit -c bandit.yml $FILES" ["radon-cc"]="pipenv run radon cc $FILES" ["radon-mi"]="pipenv run radon mi $FILES" ["xenon"]="pipenv run xenon --max-absolute D --max-modules B --max-average B $MODULE" ["pydocstyle"]="pipenv run pydocstyle $FILES" ) +LINTERS=( ["black"]="pipenv run black $CHECK $FILES" ["pylint"]="pipenv run pylint $FILES" ["flake8"]="pipenv run flake8 $FILES" ["bandit"]="pipenv run bandit -c bandit.yml $FILES" ["radon-cc"]="pipenv run radon cc $FILES" ["radon-mi"]="pipenv run radon mi $FILES" ["xenon"]="pipenv run xenon --max-absolute D --max-modules B --max-average A $MODULE" ["pydocstyle"]="pipenv run pydocstyle $FILES" ) # run each of the already configured linters for tool in "${!LINTERS[@]}"; do From b7d540f45cf703d709877b1349623986dab205bf Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Sat, 6 Jul 2019 18:11:49 -0400 Subject: [PATCH 16/19] chore: Improve the comments in the lint.sh file. --- scripts/lint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/lint.sh b/scripts/lint.sh index 28c6b4193..7cf72daf9 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -37,6 +37,9 @@ MODULE="gator" # --> cc is for calculating cyclomatic complexity # --> mi is for calculating maintainability index # - xenon returns an error code for code quality thresholds +# --> absolute: worst tolerable score for a function or block +# --> modules: worst tolerable score for a module +# --> average: worst tolerable average score across a module # define all of the linters to iteratively run declare -A LINTERS From 90590bf31cf41d57cb931f37a021e412b88a3eca Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Sat, 6 Jul 2019 18:13:30 -0400 Subject: [PATCH 17/19] chore: Try to run radon's cyclomatic complexity check in lint.bat. --- scripts/lint.bat | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/lint.bat b/scripts/lint.bat index a271cdd4b..58a18050c 100644 --- a/scripts/lint.bat +++ b/scripts/lint.bat @@ -49,6 +49,15 @@ if ERRORLEVEL 1 ( echo -- Passed ) +echo -- Running radon cc +pipenv run radon cc %FILES% +if ERRORLEVEL 1 ( + echo -- Failed + set PASSED=false +) else ( + echo -- Passed +) + if "%PASSED%"=="true" ( exit /b 0 ) else ( From b09d404d639e2d16ba3ec65be678721d51611c1c Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Sat, 6 Jul 2019 18:19:22 -0400 Subject: [PATCH 18/19] chore: Add the radon mi run to the lint.bat file. --- scripts/lint.bat | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/lint.bat b/scripts/lint.bat index 58a18050c..de14eee0f 100644 --- a/scripts/lint.bat +++ b/scripts/lint.bat @@ -58,6 +58,15 @@ if ERRORLEVEL 1 ( echo -- Passed ) +echo -- Running radon mi +pipenv run radon cc %FILES% +if ERRORLEVEL 1 ( + echo -- Failed + set PASSED=false +) else ( + echo -- Passed +) + if "%PASSED%"=="true" ( exit /b 0 ) else ( From f61645bdf88299e6989299c5221aff40b51f510b Mon Sep 17 00:00:00 2001 From: "Gregory M. Kapfhammer" Date: Sat, 6 Jul 2019 18:25:15 -0400 Subject: [PATCH 19/19] chore: Run xenon on the gator module in the lint.bat file. --- scripts/lint.bat | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/lint.bat b/scripts/lint.bat index de14eee0f..b73469139 100644 --- a/scripts/lint.bat +++ b/scripts/lint.bat @@ -67,6 +67,15 @@ if ERRORLEVEL 1 ( echo -- Passed ) +echo -- Running xenon +pipenv run xenon --max-absolute D --max-modules B --max-average A gator +if ERRORLEVEL 1 ( + echo -- Failed + set PASSED=false +) else ( + echo -- Passed +) + if "%PASSED%"=="true" ( exit /b 0 ) else (