In Scanyp, a rule refers to a Python function that identifies an issue within a code base. There are two categories of rules:
1. Rules that utilize the Scanyp object model to spot problems in the code base. The Scanyp code model encompasses the structure of the code base and the computed metrics. For example, the LOC (Lines of Code) metric can be used to detect large types.
2. Rules imported from another tool. Scanyp readily imports issues from well-known analysis tools for each language. For instance, in the case of .NET, Roslyn issues are imported, and a specific rule that captures the issues of a specific Roslyn rule can be easily created.
Scanyp comes pre-loaded with hundreds of rules, but you also have the option to swiftly create your own. You can create a new rules group for housing your rules.
Or add the rule to an existing group.
You're also given the ability to rename or delete an existing rule.
Each rule is defined by a Python function known as 'rulefunction', which must return three variables: the result array, the rule ID, and the severity.
This type of rule uses the Scanyp code model to identify potential issues. Here is an example of a basic rule:
These types of rules echo those defined by external tools. Here's an example of a straightforward rule of this kind: