From 707733552d1aac7726c5f8f8f018be2ba2aae7eb Mon Sep 17 00:00:00 2001 From: thindil Date: Thu, 11 Apr 2024 06:22:56 +0000 Subject: [PATCH] feat: continue work on checking objects' fields for standard types FossilOrigin-Name: 1309417eaeab692329861c7c547e38838fef61ef1eed3af4c46823197e6c91a4 --- src/rules/objects.nim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/rules/objects.nim b/src/rules/objects.nim index 1f686e7..88f035f 100644 --- a/src/rules/objects.nim +++ b/src/rules/objects.nim @@ -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 @@ -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]]) @@ -132,13 +131,14 @@ 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 @@ -146,6 +146,7 @@ checkRule: 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]])