commit 156f4855d0615e191c49811f913b6f03324228b6 parent e360cbbf46cd04f550946028e513aeca72cbdf99 Author: Andrew Laack <andrew@laack.co> Date: Thu, 19 Jun 2025 23:47:33 -0500 Renamed files Diffstat:
7 files changed, 60 insertions(+), 0 deletions(-)
diff --git a/tests/toml_files/default.toml b/tests/toml_files/default.toml @@ -24,11 +24,15 @@ except: except: recover()""" ] +description = "Bare except clauses catch all exceptions indiscriminately. This can hide bugs and important exceptions. To mitigate this, explicitly state the exception types that will be handled in the except clause." + [ratchet.regex.lightning] regex = "import pytorch_lightning|from pytorch_lightning" valid = ["import torch", "from my_project import Trainer"] invalid = ["import pytorch_lightning", "from pytorch_lightning import LightningModule"] +description = "The standard PyTorch library should be used in lieu of the PyTorch Lightning package." + [ratchet.regex.tabs] regex = "\\t" @@ -42,6 +46,7 @@ invalid = [ """def bar(): \treturn True""" ] +description = "As per the PEP 8 style guide for Python code, spaces are to be used instead of tabs for indentation. To mitigate this issue, run 'black FILENAME' to reformat the file with black, or manually fix the issue and update your editor to replace tabs with space." # printed text is assumed to be failures # each evaluation **must** accept a file path as input @@ -50,3 +55,4 @@ invalid = [ [ratchet.shell.line_too_long] command = "xargs -n1 awk 'length($0) > 88'" +description = "Black sets the max line-width to 88 to help with the readability of code. Ensure all lines have <89 characters. You can run 'black FILENAME' to fix this issue." diff --git a/tests/toml_files/default_no_descriptions.toml b/tests/toml_files/default_no_descriptions.toml @@ -0,0 +1,54 @@ +# these will be ran in *parallel +# (gthreads) + +[ratchet.regex.exceptions] +regex = "except:" +valid = [ + """try: + x = 1 +except ValueError: + pass""", + """try: + do_something() +except (IOError, ValueError): + handle()""" +] +invalid = [ + """ +try: + pass +except: + pass""", + """try: + dangerous() +except: + recover()""" +] + + +[ratchet.regex.lightning] +regex = "import pytorch_lightning|from pytorch_lightning" +valid = ["import torch", "from my_project import Trainer"] +invalid = ["import pytorch_lightning", "from pytorch_lightning import LightningModule"] + + +[ratchet.regex.tabs] +regex = "\\t" +valid = [ + """def foo(): + return 42""", + "print('no tab here')" +] +invalid = [ + """\tprint('starts with tab')""", + """def bar(): +\treturn True""" +] + +# printed text is assumed to be failures +# each evaluation **must** accept a file path as input +# these can be tested by running echo FILEPATH | COMMAND +# these will be ran in parallel + +[ratchet.shell.line_too_long] +command = "xargs -n1 awk 'length($0) > 88'" diff --git a/tests/toml_files/only-commands.toml b/tests/toml_files/only_commands.toml diff --git a/tests/toml_files/only-python.toml b/tests/toml_files/only_python.toml diff --git a/tests/toml_files/regexp/invalid/only-python.toml b/tests/toml_files/regexp/invalid/only_python.toml diff --git a/tests/toml_files/regexp/valid/only-commands.toml b/tests/toml_files/regexp/valid/only_commands.toml diff --git a/tests/toml_files/regexp/valid/only-python.toml b/tests/toml_files/regexp/valid/only_python.toml