Skip to content

Commit

Permalink
refactor: added getters for RuleSettings
Browse files Browse the repository at this point in the history
FossilOrigin-Name: fb1f33c6641c6bf22f02a6c552ce090ec1d8645e443a55bb1c68795b081560c7
  • Loading branch information
thindil committed Apr 5, 2024
1 parent d2800a7 commit e4862ed
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions src/rules.nim
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,36 @@ type
## * optionValues - If the rule has option type custom, the values for the option
## * minOptions - The minumal amount of options required by the rule
## * fixProc - The procedure used to auto fix the rule
name*: string
checkProc*: proc (astNode, parentNode: PNode; rule: var RuleOptions)
options*: seq[RuleOptionsTypes]
optionValues*: seq[string]
minOptions*: Natural
fixProc*: proc (astNode, parentNode: PNode; rule: RuleOptions;
name: string
checkProc: proc (astNode, parentNode: PNode; rule: var RuleOptions)
options: seq[RuleOptionsTypes]
optionValues: seq[string]
minOptions: Natural
fixProc: proc (astNode, parentNode: PNode; rule: RuleOptions;
data: string): bool

proc name*(setting: RuleSettings): string {.sideEffect, raises: [], tags: [],
contractual.} =
## Getter for field `name` of `RuleSettings` type
##
## * setting - the setting of the program's rule's configuration
##
## Returns the name of the rule
setting.name

proc checkProc*(setting: RuleSettings; astNode, parentNode: PNode;
rule: var RuleOptions) {.sideEffect, raises: [Exception], tags: [
RootEffect], contractual.} =
## Getter for field `checkProc` of `RuleSettings` type
##
## * setting - the setting of the program's rule's configuration
## * astNode - the AST node which will be checked
## * parentNode - the parent node of the node to check
## * rule - the program's rule's options
##
## Returns the name of the rule
setting.checkProc(astNode = astNode, parentNode = parentNode, rule = rule)

const availableRuleTypes*: array[4, string] = ["check", "search", "count", "fix"]
## The list of available types of the program rules

Expand Down

0 comments on commit e4862ed

Please sign in to comment.