Skip to content

Commit

Permalink
feat: continue work on checking objects' fields for standard types
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 1309417eaeab692329861c7c547e38838fef61ef1eed3af4c46823197e6c91a4
  • Loading branch information
thindil committed Apr 11, 2024
1 parent 7d7604f commit 7077335
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/rules/objects.nim
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ checkRule:
initCheck:
discard
startCheck:
let
negation: string = (if rule.negation: "'t" else: "")
message: string = (if rule.negation: "contains" else: "doesn't contain") & " public fields."
let negation: string = (if rule.negation: "'t" else: "")
checking:
var checkResult: bool = false
# Check if the object's type definition contains any public field
Expand All @@ -118,6 +116,7 @@ checkRule:
checkResult = not checkResult
let oldAmount: int = rule.amount
try:
let message: string = (if rule.negation: "contains" else: "doesn't contain") & " public fields."
setResult(checkResult = checkResult, positiveMessage = positiveMessage,
negativeMessage = negativeMessage, ruleData = "public fields",
node = node, params = [$node.info.line, message, $astNode[0]])
Expand All @@ -132,20 +131,22 @@ checkRule:
if not checkResult:
break
if rule.options[0].toLowerAscii in ["standardtypes", "all"] and node.kind == nkObjectTy:
checkResult = true
block standardTypes:
for child in node:
if child.kind == nkRecList:
for field in child:
try:
if ($field[^2]).toLowerAscii in ["int", "string"]:
checkResult = true
checkResult = false
break standardTypes
except:
discard
if rule.ruleType in {RuleTypes.count, search}:
checkResult = not checkResult
let oldAmount: int = rule.amount
try:
let message: string = (if rule.negation: "doesn't contain" else: "contains") & " field of int or string type."
setResult(checkResult = checkResult, positiveMessage = positiveMessage,
negativeMessage = negativeMessage, ruleData = "standard types",
node = node, params = [$node.info.line, message, $astNode[0]])
Expand Down

0 comments on commit 7077335

Please sign in to comment.