Package: gaplint
gaplintautomatically checks the format of a GAP file according to
some conventions, which are somewhat configurable. It prints the nature
and location of instances of any instances of violations of these
conventions (see below for more details).InstallationSimply run:$ pip install gaplintUsageTo use it:$ gaplint --helpList of all rulesTo disable all rules for a particular file you can add the line:# gaplint: disable = allto the start of the file before any lines that contain any code. All
rules are enabled by default.CodeNameRule DescriptionW000analyse-lvarsWarns if there are declared local variables that are not used or assigned but not usedW001empty-linesWarns if there are consecutive empty linesW002line-too-longWarns if there is a line which is longer than the configured maximum (defaults to 80)W003indentationWarns if a line is under indentedW004align-assignmentsWarns if there are assignments in consecutive lines that are not alignedW005align-trailing-commentsWarns if there are trailing comments in consecutive lines that are not alignedW006align-commentsWarns if there are non-trailing comments in consecutive lines that are not alignedW007trailing-whitespaceWarns if there is trailing whitespace at the end of a lineW008no-space-after-commentWarns if there is no space after any number of # is a lineW009not-enough-space-before-commentWarns if there is not enough space before the first # in any line (defaults to 2)W010space-after-commaWarns if a comma is followed by more than one spaceW011space-before-commaWarns if a comma is preceded by a spaceW012space-after-bracketWarns if there is a space after an opening bracketW013space-before-bracketWarns if there is a space before a closing bracketW014multiple-semicolonsWarns if there is more than one semicolon in a lineW015keyword-functionWarns if the keywordfunctionis not followed by an open bracketW016whitespace-op-assignWarns if there is not exactly one space after an assignment (:=)W017tabsWarns if there are tabsW018function-local-same-lineWarns if the keywordsfunctionandlocalappear in the same lineW019whitespace-op-minusWarns if there is not exactly one space either side of a minus (-) operatorW020whitespace-op-plusWarns if there is not exactly one space either side of a plus (+) operatorW021whitespace-op-multiplyWarns if there is not exactly one space either side of a multiply (*) operatorW022whitespace-op-negativeWarns if there is not exactly one space preceding a negative (-) operatorW023whitespace-op-less-thanWarns if there is not exactly one space either side of a less-than (<) operatorW024whitespace-op-less-equalWarns if there is not exactly one space either side of a less-than / equal-to (<=) operatorW025whitespace-op-more-thanWarns if there is not exactly one space either side of a greater-than(>) operatorW026whitespace-op-more-equalWarns if there is not exactly one space either side of greater than or equal to (>=) operatorW027whitespace-op-equalsWarns if there is not exactly one space either side of equals (=) operatorW028whitespace-op-mappingWarns if there is not exactly one space either side of mapping (->) operatorW029whitespace-op-divideWarns if there is not exactly one space either side of divide (/) operatorW030whitespace-op-powerWarns if there is not exactly one space either side of the power (^) operatorW031whitespace-op-not-equalWarns if there is not exactly one space either side of not-equal (<>) operatorW032whitespace-op-double-dotWarns if there is not exactly one space either side of arithmetic progression (..) operatorW033assign-then-returnWarns if a variable is assigned and then immediately returnedConfigurationCertain parameters can be configured, for example, the maximum number of
characters permitted per line. All rules are enabled by default but can
be disable at the command line, by comments in the file itself, or in a
configuration file.gaplint.yml.Configuration keywords:columns: maximum number of characters per line.Defaults to 80.max-warnings: maximum number of warnings beforegaplintaborts.Defaults to 1000.indentation: minimum indentation of nested statements.Defaults
to 2.disable: rules can be disabled using their name or code.Defaults to no rules disabled.A list of all of the rules thatgaplintcan apply is given below.You can alter the configuration in various places, the order of
precedence of these is governed by a hierarchy described below. A
preference given somewhere higher on the hierarchy than another will be
given precedence. Disabled rules accumulate through the hierarchy.ConfigurationVia the command lineThese preferences will be applied for a single run ofgaplintonly (though
multiple files may be linted in this run). To configuregaplintto be run
onfile1,file2, …, with preferences as in the example above, we
enter the following into the command line:gaplint --columns=100 --indentation=4 --disable=W002,W028 file1 file2 ...Via comments in source filesAny rule, includingall, can be suppressed for a specific line or for a
whole file:To supress a rule(s) for a given line, include the following after the line
of code for which the rule is to be suppressed:# gaplint: disable=<name_or_code>, <name_or_code> ...If the above is too long to fit after the relevant line of code,
suppressions can be declared in the line above for the line below
by including(nextline):# gaplint: disable(nextline)=<name_or_code>, <name_or_code>, ...If rules have been suppressed for a given line using both the
in-line andnextlineoptions, the union of the two rule sets
given for suppression will be disabled for the line.To suppress rules for a whole file the following must be included
before any code is written (i.e. either as the first line of a GAP
file, or preceded by any combination of only whitespace, empty
lines and comments):# gaplint: disable=<name_or_code>, <name_or_code>, ...Via a configuration fileTo configuregaplintas in the above examples, create a.gaplint.ymlfile containing the following lines:columns:100indentation:4disable:-W002-W028gaplintlooks for the.gaplint.ymlfile in the current
directory, and its ancestors, until it reaches a directory containing
agitrepository or the.gaplint.ymlfile is located. If
there is no.gaplint.ymlfile, then the default configuration
options are used. The options configured in.gaplint.ymlare
applied to every file on whichgaplintis run from the current
directory unless overruled higher in the hierarchy.