-
Notifications
You must be signed in to change notification settings - Fork 4
AA1000StaticMethodsShouldNotBeVoid
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: AA1000-StaticMethodsShouldNotBeVoid
Status | Implemented |
Description | Static methods should return a value (must not be null) |
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 are declared void
, do not meet the critia of a pure function: they will have side-effects as they do not return a result. These methods are likely to not be thread-safe or easy to test as a result. Therefore void
methods 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.
[MutatesParameter]
A static method annotated with MutatesParameter attribute is allowed to be void as it is explicitly declaring its intent to return a result through mutating the contents of a parameter.