SonarQube Plugins
  1. SonarQube Plugins
  2. SONARPLUGINS-1765

XML: If the XPath rule fails to analyse the document, it should *not* generate a violation

    Details

    • Number of attachments :
      1

      Description

      Currently, the XML plugin creates violations with the message:
      "XPath check cannot be evaluated because document is not valid"

      All those violations are by definition false positives, as they detect things which are different from the rule.

      In my opinion, it is better to simply log those errors, and not generate any violation on the file.

        Activity

        Hide
        Gordon Daugherty added a comment -

        I concur that I don't want to see XPATH rule violations appear due to the target XML being invalid. I'm attaching a patch file that makes this behavior configurable so that you by default get the original behavior or you can check a box when you create your XPATH rule to cause violations not to be generated in this situation and these cases will then only be logged during the analysis process.

        If you want to simplify this solution by removing the configurability and just providing the new "no violations in this situation" behavior that'd be ok with me also.

        I'll attach the patch file in a moment.

        Show
        Gordon Daugherty added a comment - I concur that I don't want to see XPATH rule violations appear due to the target XML being invalid. I'm attaching a patch file that makes this behavior configurable so that you by default get the original behavior or you can check a box when you create your XPATH rule to cause violations not to be generated in this situation and these cases will then only be logged during the analysis process. If you want to simplify this solution by removing the configurability and just providing the new "no violations in this situation" behavior that'd be ok with me also. I'll attach the patch file in a moment.
        Hide
        Gordon Daugherty added a comment -

        Also, I noticed that the Bamboo CI build for this software doesn't appear to run any of the unit tests. Is that intentional?

        I wasn't sure where to report this.

        See: http://bamboo.ci.codehaus.org/browse/SONAR-XML

        Show
        Gordon Daugherty added a comment - Also, I noticed that the Bamboo CI build for this software doesn't appear to run any of the unit tests. Is that intentional? I wasn't sure where to report this. See: http://bamboo.ci.codehaus.org/browse/SONAR-XML
        Hide
        Dinesh Bolkensteyn added a comment -

        Hi Gordon,

        Thanks for the patch.

        It's probably best to not allow the configurability of this, and simply not log a violation if the document is invalid (too many small configuration options will complicate the usage).
        Clearly, there must be another rule, which will log a single violation per invalid document.

        This is already the case for other languages plugins such as Java, JavaScript, etc... where you can enable the "Parsing error" rule to track files which failed to parse.

        The XML plugin has been migrated to GitHub, https://github.com/SonarCommunity/sonar-xml

        It would be nice if you could fork it, and make a pull request there, to change this behaviour.

        Also please do not integrate other changes in your patch, such as adding a requirement on Sonar 3.3 or Java 6.

        Only keep the part that relates to this ticket.

        Many thanks!

        Eric will get back to you about the unit test not being run on the CI server.

        Show
        Dinesh Bolkensteyn added a comment - Hi Gordon, Thanks for the patch. It's probably best to not allow the configurability of this, and simply not log a violation if the document is invalid (too many small configuration options will complicate the usage). Clearly, there must be another rule, which will log a single violation per invalid document. This is already the case for other languages plugins such as Java, JavaScript, etc... where you can enable the "Parsing error" rule to track files which failed to parse. The XML plugin has been migrated to GitHub, https://github.com/SonarCommunity/sonar-xml It would be nice if you could fork it, and make a pull request there, to change this behaviour. Also please do not integrate other changes in your patch, such as adding a requirement on Sonar 3.3 or Java 6. Only keep the part that relates to this ticket. Many thanks! Eric will get back to you about the unit test not being run on the CI server.
        Hide
        Eric Hartmann added a comment -

        Hi Gordon,

        As the XML plugin has been migrated to github, the CI server is now here https://sonarplugins.ci.cloudbees.com/job/xml.
        I did not notice the absence of unit tests on Bamboo, however now everything is fine on Cloudbees : https://sonarplugins.ci.cloudbees.com/job/xml/6/console

        Show
        Eric Hartmann added a comment - Hi Gordon, As the XML plugin has been migrated to github, the CI server is now here https://sonarplugins.ci.cloudbees.com/job/xml . I did not notice the absence of unit tests on Bamboo, however now everything is fine on Cloudbees : https://sonarplugins.ci.cloudbees.com/job/xml/6/console
        Hide
        Freddy Mallet added a comment -

        Manually tested !

        Show
        Freddy Mallet added a comment - Manually tested !

          People

          • Assignee:
            Julien HENRY
            Reporter:
            Dinesh Bolkensteyn
          • Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: