* fixes #20397; fixes stylecheck * add testcase
This commit is contained in:
parent
4133698f2d
commit
70c25c45d6
4 changed files with 20 additions and 0 deletions
|
|
@ -93,6 +93,7 @@ proc nep1CheckDefImpl(conf: ConfigRef; info: TLineInfo; s: PSym; k: TSymKind) =
|
||||||
template styleCheckDef*(ctx: PContext; info: TLineInfo; sym: PSym; k: TSymKind) =
|
template styleCheckDef*(ctx: PContext; info: TLineInfo; sym: PSym; k: TSymKind) =
|
||||||
## Check symbol definitions adhere to NEP1 style rules.
|
## Check symbol definitions adhere to NEP1 style rules.
|
||||||
if optStyleCheck in ctx.config.options and # ignore if styleChecks are off
|
if optStyleCheck in ctx.config.options and # ignore if styleChecks are off
|
||||||
|
{optStyleHint, optStyleError} * ctx.config.globalOptions != {} and # check only if hint/error is enabled
|
||||||
hintName in ctx.config.notes and # ignore if name checks are not requested
|
hintName in ctx.config.notes and # ignore if name checks are not requested
|
||||||
ctx.config.belongsToProjectPackage(ctx.module) and # ignore foreign packages
|
ctx.config.belongsToProjectPackage(ctx.module) and # ignore foreign packages
|
||||||
optStyleUsages notin ctx.config.globalOptions and # ignore if requested to only check name usage
|
optStyleUsages notin ctx.config.globalOptions and # ignore if requested to only check name usage
|
||||||
|
|
|
||||||
4
tests/stylecheck/t20397.nim
Normal file
4
tests/stylecheck/t20397.nim
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{.hintAsError[Name]:on.}
|
||||||
|
var a_b = 1
|
||||||
|
discard a_b
|
||||||
|
{.hintAsError[Name]:off.}
|
||||||
8
tests/stylecheck/t20397_1.nim
Normal file
8
tests/stylecheck/t20397_1.nim
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
discard """
|
||||||
|
matrix: "--styleCheck:off"
|
||||||
|
"""
|
||||||
|
|
||||||
|
{.hintAsError[Name]:on.}
|
||||||
|
var a_b = 1
|
||||||
|
discard a_b
|
||||||
|
{.hintAsError[Name]:off.}
|
||||||
7
tests/stylecheck/t20397_2.nim
Normal file
7
tests/stylecheck/t20397_2.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "'a_b' should be: 'aB'"
|
||||||
|
matrix: "--styleCheck:error"
|
||||||
|
"""
|
||||||
|
|
||||||
|
var a_b = 1
|
||||||
|
discard a_b
|
||||||
Loading…
Add table
Add a link
Reference in a new issue