Repository: hyperskill/hyperstyle (language: python)

Issue:
Sort whitelist.txt
Check in CI if Sort whitelist.txt is sorted


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c0fa5ce3..3e2c0c31 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -25,6 +25,17 @@ jobs:
           # TODO: remove R504, A003, E800, E402, WPS1, WPS2, WPS3, WPS4, WPS5, WPS6, H601
           flake8 . --count --max-complexity=11 --max-line-length=120 --max-doc-length=120 --ignore=R504,A003,E800,E402,W503,WPS1,WPS2,WPS3,WPS4,WPS5,WPS6,H601 --statistics --exclude=.git,__pycache__,docs/source/conf.py,old,build,dist,venv,test/resources,.eggs,review.egg-info,.pytest_cache,node_modules
 
+      - name: Check whitelists are sorted
+        run: |
+          for file in "whitelist.txt" "src/python/review/inspectors/flake8/whitelist.txt"
+          do
+            if ! sort -c $file
+            then
+              echo "$file is not sorted"
+              exit 1
+            fi
+          done
+
       - name: Set up Eslint
         run: |
           # Consistent with eslint version in Dockerfile
@@ -44,4 +55,4 @@ jobs:
 
       - name: Check installed module can run js linters
         run: |
-          python src/python/review/run_tool.py test/resources/inspectors/js/case0_no_issues.js
\ No newline at end of file
+          python src/python/review/run_tool.py test/resources/inspectors/js/case0_no_issues.js
diff --git a/src/python/review/inspectors/pmd/files/bin/basic.xml b/src/python/review/inspectors/pmd/files/bin/basic.xml
index 09961647..724ee58b 100644
--- a/src/python/review/inspectors/pmd/files/bin/basic.xml
+++ b/src/python/review/inspectors/pmd/files/bin/basic.xml
@@ -127,7 +127,12 @@
     <rule ref="category/java/errorprone.xml/AvoidFieldNameMatchingMethodName"/>
     <rule ref="category/java/errorprone.xml/AvoidFieldNameMatchingTypeName"/>
     <rule ref="category/java/errorprone.xml/AvoidInstanceofChecksInCatchClause"/>
-    <rule ref="category/java/errorprone.xml/AvoidLiteralsInIfCondition"/>
+    <rule ref="category/java/errorprone.xml/AvoidLiteralsInIfCondition"
+          message="Avoid using magic numbers in Conditional Statements. It is better to use constants.">
+        <properties>
+            <property name="ignoreMagicNumbers" value="-1,0,1"/>
+        </properties>
+    </rule>
     <rule ref="category/java/errorprone.xml/AvoidLosingExceptionInformation"/>
     <rule ref="category/java/errorprone.xml/AvoidMultipleUnaryOperators"/>
     <rule ref="category/java/errorprone.xml/AvoidUsingOctalValues"/>
diff --git a/whitelist.txt b/whitelist.txt
index 1d4af387..67d97c06 100644
--- a/whitelist.txt
+++ b/whitelist.txt
@@ -1,193 +1,190 @@
-capsys
-Checkstyle
-conftest
-Cyclomatic
-Detekt
-dirs
-ECMA
-EXPR
-file
-FUNC
-IGNORECASE
-INTELLIJ
-Intelli
-interop
-IssueType
-JS
-Multithreading
-Spotbugs
-SpringLint
 abstractmethod
+astype
+atclause
+bce
+binarizer
+capsys
+case18
+case34
+cbo
+changelog
+checkstyle
+cloneable
+concat
 config
+conftest
+const
+consts
+copytree
 coroutines
 csv
+ctor
+cuda
+cyclomatic
+dataflow
+dataframe
+dataframes
+dataloader
+dataset
+datasets
+dedent
 desc
-DOTALL
+detekt
+df
+dicts
+dirname
+dirs
+dit
+dont
+dotall
+dropna
+dtype
+dyn
+ecma
+eps
 eq
 eslint
 etree
+eval
+eval
 exc
+expr
 exprs
+f1
+file
+filemode
+fillna
+formatter
+fs
+fullmatch
+func
+getitem
 getline
 getroot
+getuid
 gradle
+groupby
+hashtable
+hyperstyle
+idx
+ignorecase
+iloc
 inerop
+initializer
+inplace
+instantiation
+intelli
+intellij
+interop
+isin
+isna
+isnull
+issuetype
+iterrows
 javac
+javadoc
+jpg
+js
 json
 jsons
 jsonschema
+kts
+lcom
 linecache
 lineno
+linesep
+listdir
+loc
+logits
+maintainabilities
+matcher
+mccabe
+mcs
+measurer
 min
+misrefactored
+mlb
+multilabel
+multiline
+multithreading
+namespace
+ncss
+ndarray
+nl
+nn
+noc
+nom
 noqa
+nrows
+num
+numpy
+oop
+openpyxl
+pandarallel
+param
 parametrize
+params
+parsers
 pathlib
+pickler
+plotly
 pmd
+png
+popen
+pred
+preprocess
+preprocessing
+pretrained
+println
+punisher
+puppycrawl
 pyast
 pylint
+qodana
+qodanadataset
 readouterr
+reindex
+removeprefix
 rfind
+rmdir
+runtime
+setdefault
+sigmoid
+singleline
+sklearn
+slf4j
+splitext
+spotbugs
+springlint
+sqrt
+src
+stmts
 subdir
 subdirs
+sublist
+svg
 sym
-unlink
-utils
-param
-params
-changelog
-multiline
-sqrt
-WPS
-OOP
-mccabe
-mcs
-dicts
-misrefactored
-src
 textwrap
-dedent
-maintainabilities
-parsers
-fs
-KTS
-nl
-splitext
-dirname
-hyperstyle
-XLSX
-Eval
-eval
-openpyxl
-dataframe
-writelines
-rmdir
-df
-unique
-Punisher
-# Springlint issues
-cbo
-dit
-lcom
-noc
-nom
-wmc
-util
-Namespace
-case18
-case34
 tmp
-pandarallel
-isin
-loc
-uniq
-fullmatch
-iloc
-dataframes
-numpy
-Pickler
-Unpickler
-dataset
-qodana
-listdir
-concat
-copytree
-iterrows
-nrows
-groupby
-getuid
-Popen
-reindex
-datasets
-usecols
-linesep
-plotly
-JPG
-WEBP
-SVG
-EPS
-xaxis
-preprocessing
-num
-dataloader
-dtype
-pretrained
-logits
-sigmoid
-astype
-Multilabel
 tokenizer
-pred
-Tokenizer
-bce
-nn
-warmup
-sklearn
-Binarizer
-mlb
-fillna
-inplace
-getitem
-idx
-QodanaDataset
-cuda
-f1
-WANDB
-preprocess
-PNG
-consts
-Measurer
-ndarray
-Runtime
-matcher
-pathlib
-instantiation
-initializer
-formatter
-unsynchronized
+uncommented
+uniq
+unique
 unit4
 unit5
-ncss
-hashtable
+unlink
+unpickler
+unsynchronized
+usecols
+util
+utils
 varargs
-println
-dataflow
-dont
-stmts
-cloneable
-slf4j
-removeprefix
-Javadoc
-Uncommented
-Singleline
-Xpath
-Ctor
-Atclause
-puppycrawl
-CONST
-isna
-dropna
-sublist
-dyn
-setdefault
-isnull
-filemode
+wandb
+warmup
+webp
+wmc
+wps
+writelines
+xaxis
+xlsx
+xpath


Test patch:
diff --git a/test/python/inspectors/test_pmd_inspector.py b/test/python/inspectors/test_pmd_inspector.py
index 03957f20..4a8001e6 100644
--- a/test/python/inspectors/test_pmd_inspector.py
+++ b/test/python/inspectors/test_pmd_inspector.py
@@ -84,7 +84,7 @@ def test_output_parsing(file_name: str, expected_issues: List[CodeIssue]):
 FILE_NAMES_AND_N_ISSUES = [
     ('test_algorithm_with_scanner.java', 0),
     ('test_simple_valid_program.java', 0),
-    ('test_boolean_expr.java', 2),
+    ('test_boolean_expr.java', 1),
     ('test_class_with_booleans.java', 3),
     ('test_closing_streams.java', 1),
     ('test_code_with_comments.java', 0),
@@ -105,7 +105,7 @@ def test_output_parsing(file_name: str, expected_issues: List[CodeIssue]):
     ('test_thread_run.java', 1),
     ('test_unused_imports.java', 4),
     ('test_valid_algorithm_1.java', 0),
-    ('test_valid_curly_braces.java', 1),
+    ('test_valid_curly_braces.java', 0),
     ('test_when_only_equals_overridden.java', 1),
     ('test_valid_spaces.java', 0),
 ]