Skip to content

Commit

Permalink
refactor: added some getters and setters for RuleOptions
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 5cd636b62158301d7f66bebca0793cf45ecd2cd8cebd4e77f157fd88b9f47679
  • Loading branch information
thindil committed Apr 5, 2024
1 parent e4862ed commit c720955
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions src/rules.nim
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ type
## * explanation - The explanation which will be show to the user if check
## or fix type of rule setting is violated by the checked
## code
options*: seq[string]
parent*: bool
options: seq[string]
parent: bool
fileName*: string
negation*: bool
ruleType*: RuleTypes
Expand Down Expand Up @@ -95,6 +95,44 @@ type
fixProc: proc (astNode, parentNode: PNode; rule: RuleOptions;
data: string): bool

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

proc `options=`*(opt: var RuleOptions; value: seq[string]) {.sideEffect,
raises: [], tags: [], contractual.} =
## Setter for field `options` of `RuleOptions` type
##
## * opt - the options of the program's rule's configuration which will be updated
## * value - the new value for the field
##
## Returns modified the program's rule's options
opt.options = value

proc parent*(opt: RuleOptions): bool {.sideEffect, raises: [], tags: [],
contractual.} =
## Getter for field `parent` of `RuleOptions` type
##
## * opt - the options of the program's rule's configuration
##
## Returns the value of the `parent` field of the rule's options
opt.parent

proc `parent=`*(opt: var RuleOptions; value: bool) {.sideEffect,
raises: [], tags: [], contractual.} =
## Setter for field `parent` of `RuleOptions` type
##
## * opt - the options of the program's rule's configuration which will be updated
## * value - the new value for the field
##
## Returns modified the program's rule's options
opt.parent = value

proc name*(setting: RuleSettings): string {.sideEffect, raises: [], tags: [],
contractual.} =
## Getter for field `name` of `RuleSettings` type
Expand Down

0 comments on commit c720955

Please sign in to comment.