#349 LineLengthCheck shall be able to ignore trailing spaces

Future
closed
nobody
5
2014-07-25
2005-02-22
Daniel Sun
No

The LineLenghtCheck shall ignore trailing spaces or the
behavior shall be configurable.

In LineLengthCheck.java

public void beginTree(DetailAST aRootAST)
{
final String[] lines = getLines();
for (int i = 0; i < lines.length; i++) {

        final String line = lines[i];
        // suggested change
        // final String line = lines[i].trim();

        final int realLength = Utils.lengthExpandedTabs(
            line, line.length(), getTabWidth());

        if (realLength > mMax && !

mIgnorePattern.match(line)) {
log(i + 1, "maxLineLen", new Integer(mMax));
}
}
}

Discussion

  • Oleg Sukhodolsky

    Logged In: YES
    user_id=746148

    Why you don't want remove trailing spaces from the code IMHO
    they are annoying thing?
    About suggested fix: I don't think that trim() works here,
    because it will remove not only trailing spaces, but also
    spaces at the begining of the string.

     
  • Daniel Sun

    Daniel Sun - 2005-02-22

    Logged In: YES
    user_id=345986

    You are right, the trim() won't work.

    It is not that difficult to remove all trailing spaces in the
    source code with a script. For some reason, those trailing
    spaces will reappear randomly in the code again. They either
    come from IDE or our auto format tool. It will be nice that
    checkstyle can ignore them instead of we have to run the
    space removing tool everytime there is a problem. It is just a
    nice feature to have in my opnion, not a priority though.

     
  • Oleg Sukhodolsky

    Logged In: YES
    user_id=746148

    Ok, I change it to RFE

     
  • Daniel Sun

    Daniel Sun - 2005-02-22

    Logged In: YES
    user_id=345986

    thanks

     
  • Roman Ivanov

    Roman Ivanov - 2014-07-25

    this feature is rejected, will never be implemented in Checkstyle.

    extra spaces/symbols/experssion should be resolved by human or script(formater).

     
  • Roman Ivanov

    Roman Ivanov - 2014-07-25
    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks