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

org.sonar.plugins.csharp.S2857.html Maven / Gradle / Ivy

There is a newer version: 10.2.0.105762
Show newest version

Why is this an issue?

When concatenating strings, it is very easy to forget a whitespace.

In some scenarios this might cause runtime errors, one of which is while creating an SQL query via concatenation:

string select = "SELECT p.FirstName, p.LastName, p.PhoneNumber" +
        "FROM Person as p" +    // Noncompliant: concatenation results in "p.PhoneNumberFROM"
        "WHERE p.Id = @Id";     // Noncompliant: concatenation results in "pWHERE"

This rule raises an issue when the spacing around SQL keywords appears to be missing, making the concatenated string invalid SQL syntax. It would require the user to add the appropriate whitespaces:

string select = "SELECT p.FirstName, p.LastName, p.PhoneNumber" +
        " FROM Person as p" +
        " WHERE p.Id = @Id";




© 2015 - 2024 Weber Informatics LLC | Privacy Policy