rsc-implied-declaration
a declaration Ur makes for every rule module, written out again.
- Group
- Code
- Runs
- On by default
- Level
- warning
- Reads
- Every file
- Fix
- None: a deletion leaves the lines and comments around it for the author to tidy
Why
Ur declares the data types of the facts hosts read, Language, Check, Change, Insert, Commented, Field, Rewrite, Classify, and Rank, and the functions hosts give for names and types, such as definition and typeOf, wherever a module uses one without declaring it. A declaration that restates one only repeats what the loader already knows.
The fix, as Ur suggests it: delete the declaration.
For agents
Do not declare data Language, data Check, data Change, data Insert, data Commented, data Field, data Rewrite, data Classify, or data Rank, nor param the host's name and type functions such as definition(Tree n): Ur declares them.
Example
checks/Options.rscmodule checks::Options
data Check = check(str attribute, str message);
param str definition(Tree n);
check(optionRead, "a session option is read");
$ ur lint --rule rsc-implied-declaration
warning[rsc-implied-declaration]: `data Check = check(str attribute, str message);` is declared for every rule module; delete it
--> ./checks/Options.rsc:3:1 `data Check = check(str attribute, str message);`
= hint: delete the declaration
warning[rsc-implied-declaration]: `param str definition(Tree n);` is declared for every rule module; delete it
--> ./checks/Options.rsc:4:1 `param str definition(Tree n);`
= hint: delete the declaration
0 clone classes and 2 `rsc-implied-declaration` findings in 1 file