Skip to content

Commit

Permalink
refactor: added constructor for RuleOptions
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 927f93bbe96d7a62cdc50b5e045355e3e158a4919dd8a85495723690d4e95235
  • Loading branch information
thindil committed Jun 5, 2024
1 parent 0bb6bf1 commit 73777c5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/rules.nim
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,39 @@ type
fixProc: proc (astNode, parentNode: PNode; rule: RuleOptions;
data: string): bool

proc initRuleOptions*(options: seq[RuleOption] = @[]; parent: bool = false;
fileName: FilePath = ""; negation: bool = false; ruleType: RuleTypes = none;
amount: ResultAmount = 0; enabled: bool = true; fixCommand: FixCommand = "";
identsCache: IdentCache = nil; forceFixCommand: bool = false;
maxResults: Natural = Natural.high;
explanation: Message = ""): RuleOptions {.sideEffect, raises: [], tags: [],
contractual.} =
## Initialize a new instance of RuleOptions object
##
## * options - The list of the program's rule's options
## * parent - If true, check is currently make in the parent (usualy
## module) entity
## * fileName - The path to the file which is checked
## * negation - If true, the rule show return oposite result
## * ruleType - The type of rule
## * amount - The amount of results found by the rule
## * enabled - If false, the rule is temporary disabled by pragmas
## * fixCommand - The command executed by the rule if no custom code is set
## for fix type of rule
## * identsCache - The Nim identifiers cache
## * forceFixCommand - If true, force the rule to use fixCommand instead of its
## fix code
## * explanation - The explanation which will be show to the user if check
## or fix type of rule setting is violated by the checked
## code
##
## Returns the new instance of RuleOptions object
return RuleOptions(options: options, parent: parent, fileName: fileName,
negation: negation, ruleType: ruleType, amount: amount, enabled: enabled,
fixCommand: fixCommand, identsCache: identsCache,
forceFixCommand: forceFixCommand, maxResults: maxResults,
explanation: explanation)

template optionsGetterSetter(name: untyped; typ: typedesc) =
## Set the getter for a field of RuleOptions type
##
Expand Down

0 comments on commit 73777c5

Please sign in to comment.