Skip to content

Commit

Permalink
tests: updated nimalyzer configuration to prevent some problems with …
Browse files Browse the repository at this point in the history
…the current version of nimalyzer

FossilOrigin-Name: 3481d600fc2b0911b95b1521412964d797512de8d422f6c438bf4249fd3a2764
  • Loading branch information
thindil committed Nov 3, 2024
1 parent 0941073 commit 24721cb
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion tools/nimalyzer.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
maxreports 20
output new nimalyzer.log
directory src
directory tests
ignore src/helpcontent.nim
showSummary true

Expand Down Expand Up @@ -64,3 +63,66 @@ explanation Each object should have constructors and use them for creating new i

check not vardeclared standardtypes
explanation Using standard types like string or int can lead to hard to find bugs when wrong variables are interacting with self. Also, using a separated types give more information about the variable.

reset
directory tests

message Checking the program's tests, temporary setting before nimalyzer will be fixed
check hasPragma unborrowed contractual "raises: [*" "tags: [*"
explanation Contracts helps in testing the program and all declared procedures should have declared contracts for them. The procedures should avoid raising exceptions and handle each possible exception by themselves for greater stability of the program. The information about the effects system by tags pragma can also help in understanding what exactly the procedure doing.
check params used all
explanation Unused parameters only clutter the source code and can cause confusion.
check not params standardtypes procedures
explanation Using standard types like string or int can lead to hard to find bugs when wrong parameters are interacting with self. Also, using a separated types give more information about the parameter.
check namedParams
explanation Named parameters allow avoiding assigning invalid values to the calls but also allow to assing the calls' parameters in arbitrary order.

check hasDoc all
explanation The documentation is a love's letter to your future self. :) Documentation make our lives easier, especially if we have return to the code after a longer period of time.
check varDeclared full
explanation The full declaration of variables gives information about their types and sets the initial values for them which can prevent sometimes in hard to detect errors, when the default values change.
check varUplevel
explanation The proper usage of var, let and const types of declaration make the code more readable and prevent from invalid assigning to a variable which shouldn't be assigned.

check localHides
explanation If a local variable has the same name as a global one declared in the same scope, it can lead to hard to read code or even invalid assign to the variable.

check ifStatements all
explanation All the rules enabled make the code more readable. Empty statements are just a dead code. If the statement contains a finishing statment, like return or raise, then it is better to move its following brach outside the statement for better readability. Also using positive conditions in the starting expression helps in preventing in some logical errors.

check not forStatements iterators
explanation There is no need to write information about usage of pairs or items iterators, it can be read directly from the code from the first part of the for statement declaration.

check forStatements empty
explanation Empty statements are just a dead code which made the code harder to read.

check comments legal
explanation Each source code file should have the legal information, required by BSD-3 license.

check assignments shorthand
explanation Shorthand assignments are shorter to write and can be more readable, especially with long names of variables.

check caseStatements min 3
explanation Short case statements can be replaced by if statements for better readablity.

check ifStatements max 3
explanation Long if statements can be replaced by case statements for better readability.

check complexity all 40
explanation A code with high cyclomatic complexity is hard to understand and maintain. Please reduce the amount of the code branches (like, loops, if or case statements).

check not trystatements empty
explanation Except branches with names of exceptions made code more readable. It also prevents problems when the checked code will start propagating new exceptions.

check not objects fields
explanation Each object's declaration should define also getters and setters for its fields. It made maintaining the code easier, when the type will be upgraded or required to use in multithread environment.
check not vardeclared standardtypes
explanation Using standard types like string or int can lead to hard to find bugs when wrong variables are interacting with self. Also, using a separated types give more information about the variable.

0 comments on commit 24721cb

Please sign in to comment.