Skip to content

CLI should print a flie name where exception is happen #2109

Closed

Description

@romani
java -jar checkstyle-6.10.1-all.jar -c sun_checks.xml *.java

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.AbstractStringBuilder.charAt(Unknown Source)
        at java.lang.StringBuilder.charAt(Unknown Source)
        at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.trimTail(JavadocStyleCheck.java:315)
        at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.getCommentText(JavadocStyleCheck.java:269)
        at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.checkFirstSentenceEnding(JavadocStyleCheck.java:230)
        at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.checkComment(JavadocStyleCheck.java:207)
        at com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocStyleCheck.visitToken(JavadocStyleCheck.java:148)
        at com.puppycrawl.tools.checkstyle.TreeWalker.notifyVisit(TreeWalker.java:392)
        at com.puppycrawl.tools.checkstyle.TreeWalker.processIter(TreeWalker.java:503)
        at com.puppycrawl.tools.checkstyle.TreeWalker.walk(TreeWalker.java:334)
        at com.puppycrawl.tools.checkstyle.TreeWalker.processFiltered(TreeWalker.java:209)
        at com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck.process(AbstractFileSetCheck.java:79)
        at com.puppycrawl.tools.checkstyle.Checker.process(Checker.java:265)
        at com.puppycrawl.tools.checkstyle.Main.runCheckstyle(Main.java:271)
        at com.puppycrawl.tools.checkstyle.Main.main(Main.java:121)

So where is no easy way to find a reason (input file) of problem. File path should be printed.

Activity

  1. romani commented on Oct 13, 2015

    @romani
    MemberAuthor

    Getting details failure is almost impossible now, we need to address this ASAP.

    See #2327 , #2326 .

  2. Vampire commented on Oct 13, 2015

    @Vampire
    Contributor

    I don't think this is related to #2326, there the real error is not shown at all, but the previously found one :-)

  3. added a commit that references this issue on Oct 30, 2015
  4. romani commented on Oct 30, 2015

    @romani
    MemberAuthor

    @mkordas , do you have better approach to fix this ? (see my non merged commit and PR)

  5. romani commented on Oct 30, 2015

    @romani
    MemberAuthor

    We need to catch and rethrow with context information (file path) in Exception as we do not know how our code is used (plugin, embedded, ....), we can not reply on logger, as it could be switched off.

  6. added 5 commits that reference this issue on Oct 30, 2015
  7. mkordas commented on Oct 31, 2015

    @mkordas
    Contributor

    @romani, I like the approach.

  8. added 4 commits that reference this issue on Nov 1, 2015
  9. added this to the 6.12 milestone on Nov 1, 2015
  10. romani commented on Nov 1, 2015

    @romani
    MemberAuthor

    merged.

    See discussions at #2476 , #2487 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions