Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use nimlint to enforce best practices #16272

Closed
wants to merge 1 commit into from

Conversation

ringabout
Copy link
Member

@ringabout ringabout commented Dec 6, 2020

Ref RFC timotheecour#415 and https://github.com/nim-compiler-dev/nimlint

Before this PR

D:\QQPCmgr\Desktop\Nim>nimlint -i=lib/pure/distros.nim -o:out.nim --verbose=true
[lint] hintCodeBlocks: D:\QQPCmgr\Desktop\Nim\lib\pure\distros.nim(21)
code blocks => runnableExamples

[lint] hintBackticks: D:\QQPCmgr\Desktop\Nim\lib\pure\distros.nim(204)
double backticks => single backtick

After this PR

D:\QQPCmgr\Desktop\Nim>nimlint -i=lib/pure/distros.nim -o:out.nim --verbose=true

@timotheecour timotheecour changed the title use nimlint to make sure best practices use nimlint to enforce best practices Dec 6, 2020
##
##
runnableExamples:
if detectOs(Ubuntu):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if defined(nimEnableExtraExamples) and detectOs(Ubuntu):
   ...

that way it won't actually run the install commands on ubuntu simply because you ran nim doc

and if instead of when so that nim doc checks that the disabled block compiles

@@ -201,7 +198,7 @@ proc detectOsImpl(d: Distribution): bool =

template detectOs*(d: untyped): bool =
## Distro/OS detection. For convenience the
## required ``Distribution.`` qualifier is added to the
## required `Distribution.` qualifier is added to the
Copy link
Member

@timotheecour timotheecour Dec 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this relies on nimlint automation, why not try it on a larger set of files, eg lib/pure/* or even lib/*, and, say, just do it for 1 linter check (double backticks => single backticks) (single lint category makes reviewing easier)

and see whether there are adjustments required (stress test for nimlint)

@ringabout ringabout marked this pull request as draft December 7, 2020 09:43
@ringabout ringabout closed this Dec 29, 2020
@timotheecour timotheecour added the stale Staled PR/issues; remove the label after fixing them label Dec 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Staled PR/issues; remove the label after fixing them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants