gap(https://www.gap-system.org/)代码的基本皮棉。
gaplint的Python项目详细描述
gaplint根据 一些约定,有些是可配置的。它印证了自然 以及违反这些规定的任何实例的位置 约定(详见下文)。
安装
只需运行:
$ pip install gaplint
用法
使用它:
$ gaplint --help
所有规则的列表
要禁用特定文件的所有规则,可以添加以下行:
# gaplint: disable = all
在包含任何代码的任何行之前打开文件。全部 默认情况下启用规则。
Code | Name | Rule Description |
---|---|---|
^{tt2}$ | ^{tt3}$ | Warns if there are declared local variables that are not used or assigned but not used |
^{tt4}$ | ^{tt5}$ | Warns if there are consecutive empty lines |
^{tt6}$ | ^{tt7}$ | Warns if there is a line which is longer than the configured maximum (defaults to 80) |
^{tt8}$ | ^{tt9}$ | Warns if a line is under indented |
^{tt10}$ | ^{tt11}$ | Warns if there are assignments in consecutive lines that are not aligned |
^{tt12}$ | ^{tt13}$ | Warns if there are trailing comments in consecutive lines that are not aligned |
^{tt14}$ | ^{tt15}$ | Warns if there are non-trailing comments in consecutive lines that are not aligned |
^{tt16}$ | ^{tt17}$ | Warns if there is trailing whitespace at the end of a line |
^{tt18}$ | ^{tt19}$ | Warns if there is no space after any number of # is a line |
^{tt20}$ | ^{tt21}$ | Warns if there is not enough space before the first # in any line (defaults to 2) |
^{tt22}$ | ^{tt23}$ | Warns if a comma is followed by more than one space |
^{tt24}$ | ^{tt25}$ | Warns if a comma is preceded by a space |
^{tt26}$ | ^{tt27}$ | Warns if there is a space after an opening bracket |
^{tt28}$ | ^{tt29}$ | Warns if there is a space before a closing bracket |
^{tt30}$ | ^{tt31}$ | Warns if there is more than one semicolon in a line |
^{tt32}$ | ^{tt33}$ | Warns if the keyword function is not followed by an open bracket |
^{tt34}$ | ^{tt35}$ | Warns if there is not exactly one space after an assignment (:=) |
^{tt36}$ | ^{tt37}$ | Warns if there are tabs |
^{tt38}$ | ^{tt39}$ | Warns if the keywords function and local appear in the same line |
^{tt40}$ | ^{tt41}$ | Warns if there is not exactly one space either side of a minus (-) operator |
^{tt42}$ | ^{tt43}$ | Warns if there is not exactly one space either side of a plus (+) operator |
^{tt44}$ | ^{tt45}$ | Warns if there is not exactly one space either side of a multiply (*) operator |
^{tt46}$ | ^{tt47}$ | Warns if there is not exactly one space preceding a negative (-) operator |
^{tt48}$ | ^{tt49}$ | Warns if there is not exactly one space either side of a less-than (<) operator |
^{tt50}$ | ^{tt51}$ | Warns if there is not exactly one space either side of a less-than / equal-to (<=) operator |
^{tt52}$ | ^{tt53}$ | Warns if there is not exactly one space either side of a greater-than(>) operator |
^{tt54}$ | ^{tt55}$ | Warns if there is not exactly one space either side of greater than or equal to (>=) operator |
^{tt56}$ | ^{tt57}$ | Warns if there is not exactly one space either side of equals (=) operator |
^{tt58}$ | ^{tt59}$ | Warns if there is not exactly one space either side of mapping (->) operator |
^{tt60}$ | ^{tt61}$ | Warns if there is not exactly one space either side of divide (/) operator |
^{tt62}$ | ^{tt63}$ | Warns if there is not exactly one space either side of the power (^) operator |
^{tt64}$ | ^{tt65}$ | Warns if there is not exactly one space either side of not-equal (<>) operator |
^{tt66}$ | ^{tt67}$ | Warns if there is not exactly one space either side of arithmetic progression (..) operator |
配置
某些参数可以被配置,例如 每行允许字符数。默认情况下启用所有规则,但可以 在命令行、文件本身中的注释或 配置文件.gaplint.yml。配置关键字:
- ^ TT69}$:每行最大字符数。默认值为80。 < $ }:最大警告数之前 中止。默认值为1000。
- indentation:嵌套语句的最小缩进。默认值 到2。
- disable:可以使用规则的名称或代码禁用规则。 默认为不禁用任何规则。
下面列出了gaplint可以应用的所有规则。
您可以在不同的位置更改配置,顺序是 它们的优先级由下面描述的层次结构控制。一个 在等级制度中给予比其他地方更高的优先权 优先权。禁用的规则通过层次结构累积。
配置
通过命令行
这些首选项将仅应用于gaplint的一次运行(尽管 在此运行中可能会对多个文件进行lint)。将gaplint配置为运行 在file1,file2,…,使用上面示例中的首选项,我们 在命令行中输入以下命令:
gaplint --columns=100 --indentation=4 --disable=W002,W028 file1 file2 ...
通过源文件中的注释
任何规则,包括all,都可以针对特定行或 整个文件:
若要对给定行抑制规则,请在该行之后包含以下内容 要禁止规则的代码数:
# gaplint: disable=<name_or_code>, <name_or_code> ...
如果上面的代码太长,不适合在相关代码行之后, 可以在上面的行中为下面的行声明抑制 包括(nextline):
# gaplint: disable(nextline)=<name_or_code>, <name_or_code>, ...
如果给定行的规则已被抑制,则使用 in line和nextline选项,两个规则集的并集 将对线路禁用“给定抑制”。
要取消整个文件的规则,必须包括以下内容 在编写任何代码之前(即作为间隙的第一行 文件,或前面只有空格的任意组合,为空 行和注释):
# gaplint: disable=<name_or_code>, <name_or_code>, ...
通过配置文件
To configure ^{tt1}$ as in the above examples, create a ^{tt68}$ file containing the following lines:
columns:100indentation:4disable:-W002-W028
gaplint在当前文件中查找.gaplint.yml文件 目录及其祖先,直到它到达包含 找到了git存储库或.gaplint.yml文件。如果 没有.gaplint.yml文件,则为默认配置 使用选项。在.gaplint.yml中配置的选项有 应用于当前运行gaplint的每个文件 目录,除非在层次结构中被否决。