ratchets

Mirror of ratchets, my python testing utility
git clone git://git.laack.co/ratchets.git
Log | Files | Refs | README | LICENSE

default.toml (1790B)


      1 # these will be ran in *parallel
      2 # (gthreads)
      3 
      4 [ratchet.regex.exceptions]
      5 regex = "except:"
      6 valid = [
      7   """try:
      8     x = 1
      9 except ValueError:
     10     pass""",
     11   """try:
     12     do_something()
     13 except (IOError, ValueError):
     14     handle()"""
     15 ]
     16 invalid = [
     17   """
     18 try:
     19     pass
     20 except:
     21     pass""",
     22   """try:
     23     dangerous()
     24 except:
     25     recover()"""
     26 ]
     27 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."
     28 
     29 
     30 [ratchet.regex.lightning]
     31 regex = "import pytorch_lightning|from pytorch_lightning"
     32 valid = ["import torch", "from my_project import Trainer"]
     33 invalid = ["import pytorch_lightning", "from pytorch_lightning import LightningModule"]
     34 description = "The standard PyTorch library should be used in lieu of the PyTorch Lightning package."
     35 
     36 
     37 [ratchet.regex.tabs]
     38 regex = "\\t"
     39 valid = [
     40   """def foo():
     41     return 42""",
     42   "print('no tab here')"
     43 ]
     44 invalid = [
     45   """\tprint('starts with tab')""",
     46   """def bar():
     47 \treturn True"""
     48 ]
     49 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."
     50 
     51 # printed text is assumed to be failures
     52 # each evaluation **must** accept a file path as input
     53 # these can be tested by running echo FILEPATH | COMMAND
     54 # these will be ran in parallel
     55 
     56 [ratchet.shell.line_too_long]
     57 command = "xargs -n1 awk 'length($0) > 88'"
     58 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."