Skip to content

Gendarme.Rules.Correctness.DoNotRoundIntegersRule(2.10)

Sebastien Pouliot edited this page Jan 22, 2011 · 2 revisions

DoNotRoundIntegersRule

Assembly: Gendarme.Rules.Correctness
Version: 2.10

Description

This rule check for attempts to call Round, Ceiling, Floor or Truncate on an integral type. This often indicate a typo in the source code (e.g. wrong variable) or an unnecessary operation.

Examples

Bad example:

public decimal Compute (int x)
{
    return Math.Truncate ((decimal) x);
}

Good example:

public decimal Compute (int x)
{
    return (decimal) x;
}

Notes

  • This rule is available since Gendarme 2.0
Clone this wiki locally