forked from nim-lang/Nim
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
goal: a tool that would increase automation, improve quality of existing code and PR's, decrease time spent by reviewers in reviewing PR's.
This would use compilerapi.nim to give same access to code as what nim has, or be built into nim if it's simpler to do so (like --styleCheck on steroids).
This would be usable both as a library and as cmdline:
as cmdline, it'd accept all options accepted by nim, eg:
nimlint -d:foo -b:js bar.nim
As library code, TBD.
Some small number of false positive recommendations are acceptable
The linter should be customizable (in particular to suite ones needs in their third party code).
lint items
- code block => runnableExamples
- rst code blocks without a test => recommend using a
test(eg:test: "nim c $1"; perhaps with:status: 1) - proc + noSideEffect => func
- assert in a test file => doAssert
- isMainModule in stdlib => recommend moving to tests/stdlib/tfoo.nim
- double backticks => single backtick
- capitalize the first letter
- lots of testament specific checks (eg
exitcode: 0usually useless) - etc, countless things that would be best done as a tool instead of relying on every reviewer to check all of those in every PR (plus for making it easier to improve stdlib + third party projects)
- check for presence of multiple yield statements in inline iterators, which cause code bloat
- see also: https://nim-lang.github.io/Nim/contributing.html#best-practices
- naming style https://nim-lang.github.io/Nim/nep1.html
features
- syntax to ignore lint recommendations, analog to
#!nimpretty off
(maybe via a pragma or special#!nimlint:offsyntax)
extension: nimfix
- nimfix could be revived but it's a more complex problem than simply reporting issues (where false positives aren't as bad as bad fixes), so can be discussed separately; can be combined with nimpretty to enforce style
/cc @xflywind what do you think? feel free to add to this lint items list
links
- use nimlint to enforce best practices nim-lang/Nim#16272
- https://github.com/nim-compiler-dev/nimlint
- https://github.com/timotheecour/vitanim/wiki/Nim-best-practices
- juancarlospaco/nimlint-action: Nimlint GitHub Action
- lint+ - an improved linter for the lite text editor, incl. Nim support - Nim forum
Reactions are currently unavailable