Skip to content

AA1000StaticMethodsShouldNotBeVoid

David Arno edited this page Jul 18, 2016 · 1 revision

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.


AA1000 - Static Methods Should Not Be Void

Report code: AA1000-StaticMethodsShouldNotBeVoid

Summary

Status Implemented
Description Static methods should return a value (must not be null)
Category Pure-Function Analyzers
Enabled by default: Yes
Severity: Error

Cause

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.

How to fix violations

There currently aren't any implemented code-fixes for this rule.

How to suppress violations

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.