All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.delphi.rules.community-delphi.DigitSeparator.html Maven / Gradle / Ivy

The newest version!

Why is this an issue?

From Delphi 11 onwards, digit separators _ can be used to split numeric literals into groups.

To improve readability, this rule verifies that numeric literals above a configurable size in digits use separators.

Noncompliant code example
  const
    DecimalInt     = 10000;      // Noncompliant; more than 4 digits without separators
    HexadecimalInt = $7FFFF;     // Noncompliant; more than 4 digits without separators
    BinaryInt      = %01010;     // Noncompliant; more than 4 digits without separators
    Float          = 10000.0;    // Noncompliant; more than 4 (integer) digits without separators
Compliant code example
  const
    DecimalInt       = 10_000;
    HexadecimalInt   = $7_FFFF;
    BinaryInt        = %0_10_10;
    LongDecimalFloat = 10_000.0;
    FloatWithAnySeps = 10.0_0_00_1;
    FloatWithoutSeps = 10.00001;

Exceptions

Only the integer component of floating point numbers is checked for compliance; the fractional and exponent parts are ignored.

How to fix it

  1. Group the digits in the number using _ between groups.

Resources





© 2015 - 2024 Weber Informatics LLC | Privacy Policy