Skip to content

Commit

Permalink
feat: continue work on adding ability to check standard types in rout…
Browse files Browse the repository at this point in the history
…ines declarations

FossilOrigin-Name: d42525db1f909a5cb35511251320ead7162ae13a2d645d6b5618bbf057e88662
  • Loading branch information
thindil committed Jun 10, 2024
1 parent d85e2d2 commit e325b73
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/rules/params.nim
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ import compiler/trees
import ../rules

ruleConfig(ruleName = "params",
ruleFoundMessage = "procedures which{negation} use all parameters",
ruleNotFoundMessage = "procedures which{negation} use all parameters not found.",
ruleFoundMessage = "procedures which{negation} {ruleCheck}",
ruleNotFoundMessage = "procedures which{negation} {ruleCheck} not found.",
rulePositiveMessage = "procedure {params[0]} line: {params[1]}{params[2]} use all its parameters.",
ruleNegativeMessage = "procedure {params[0]} line: {params[1]} doesn't use parameter '{params[2]}'.",
ruleOptions = @[str, custom],
Expand Down Expand Up @@ -160,7 +160,8 @@ checkRule:
return
# Check if the routine uses standard types for its parameters
if rule.options[0].toLowerAscii in ["all", "standardtypes"]:
echo varName
if $child[^2] in ["int", "string"]:
echo varName, " standard type"
except KeyError, Exception:
rule.amount = errorMessage(text = messagePrefix &
"can't check parameters of procedure " & procName &
Expand All @@ -172,7 +173,17 @@ checkRule:
negativeMessage = positiveMessage, node = node, params = [
procName, $node.info.line, ""])
endCheck:
let negation: Message = (if rule.negation: " not" else: "")
let
negation: Message = (if rule.negation: " not" else: "")
ruleCheck: Message = case rule.options[0].toLowerAscii
of "all":
"pass all checks"
of "used":
"use all parameters"
of "standardtypes":
"contain int or string as type of parameters"
else:
""

fixRule:
# Don't change anything if rule has negation
Expand Down

0 comments on commit e325b73

Please sign in to comment.