-
Notifications
You must be signed in to change notification settings - Fork 4
AA1001StaticMethodsShouldHaveAtLeastOneParameter
Warning: this wiki page is auto-generated by the Arnolyzer solution-build process. Do not directly edit this page, as your changes will be lost on the next commit. To edit this page, please refer to Contributing to this project.
These wiki pages reflect the state of the project in development, per the last commit. For details of the latest release of the Arnolyzer Analysers, please see the Arnolyzer website.
Report code: AA1001-StaticMethodsShouldHaveAtLeastOneParameter
Status | Implemented |
Description | Static methods should have at least one parameter |
Category | Pure-Function Analyzers |
Enabled by default: | Yes |
Severity: | Error |
Static methods that take an input, and generate a deterministic output from that input, without having any side-effects are termed pure functions. These methods are thread-safe and easy to test.
Static methods that do not take any parameters, do not meet the critia of a pure function: they will have side-effects as they must derive a result from external resources. These methods are likely to not be thread-safe or easy to test as a result. Therefore methods without parameters should not be made static.
There currently aren't any implemented code-fixes for this rule.
This rule can be suppressed using the following attributes:
[HasSideEffects]
A static method annotated with HasSideEffects attribute is allowed to be void and have no parameters as it is explicitly declaring its intent to cause side effects.
[ConstantValueProvider]
A static method annotated with ConstantValueProvider attribute is allowed have no parameters as it is explicitly guaranteeing to return the same result every time it's called.
For example, a static factory method that generates the same shape object each time it's called can use this annotation.