SonarQube
  1. SonarQube
  2. SONAR-3305

When there isn't any description or title available on a rule, a NullPointerException is thrown

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.0
    • Component/s: Quality Profile
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Whereas we expect exception during server startup with a meaninful message, which clearly says which plugin and which rule has no title or description.

      For the information in Sonar 2.14-RC1 error when description not available looks like :

      2012.03.06 12:19:50 ERROR o.s.s.ui.JRubyFacade  Fail to render: http://localhost:9000/rules_configuration/index/4?searchtext=&plugins%5B%5D=cppcheck&priorities%5B%5D=&rule_status=&commit=Search
      undefined method `strip' for nil:NilClass
              On line #10 of app/views/rules_configuration/_rule_note.html.erb
      
          7: submit_note_update_button_id = "snub_" + rule.id.to_s
          8: %>
          9: <div id="<%= note_detail_div_id -%>">
          10: <% if rule.description.strip.start_with?('<p>') %>
          11: <%= rule.description %>
          12: <% else %>
          13: <p><%= rule.description %></p>
      
          app/views/rules_configuration/_rule_note.html.erb:10
          org/jruby/RubyKernel.java:2056:in `send'
          app/views/rules_configuration/_rule.html.erb:37
          org/jruby/RubyKernel.java:2056:in `send'
          app/views/rules_configuration/index.html.erb:116
          org/jruby/RubyArray.java:1602:in `each'
          app/views/rules_configuration/index.html.erb:112
          org/jruby/RubyKernel.java:2056:in `send'
          org/jruby/RubyKernel.java:2052:in `send'
          org/jruby/RubyProc.java:268:in `call'
          org/jruby/RubyProc.java:228:in `call'
          /tmp/sonar/tomcat6x/work/Catalina/localhost/_/loader/vendor/rack-1.2.1/rack/head.rb:9:in `call'
          /tmp/sonar/tomcat6x/work/Catalina/localhost/_/loader/vendor/rack-1.2.1/rack/methodoverride.rb:24:in `call'
          /tmp/sonar/tomcat6x/work/Catalina/localhost/_/loader/jruby/rack/session_store.rb:42:in `call'
          /tmp/sonar/tomcat6x/work/Catalina/localhost/_/loader/rack/adapter/rails.rb:36:in `serve_rails'
          /tmp/sonar/tomcat6x/work/Catalina/localhost/_/loader/rack/adapter/rails.rb:41:in `call'
          /tmp/sonar/tomcat6x/work/Catalina/localhost/_/loader/jruby/rack/rails.rb:185:in `call'
          /tmp/sonar/tomcat6x/work/Catalina/localhost/_/loader/rack/handler/servlet.rb:19:in `call'
      

      and when title not available :

      undefined method `downcase' for nil:NilClass
              /tmp/sonar/tomcat6x/temp/0-ROOT/WEB-INF/app/models/rule.rb:69:in `<=>'
              org/jruby/RubyArray.java:3242:in `sort!'
              org/jruby/RubyArray.java:3221:in `sort'
              /tmp/sonar/tomcat6x/temp/0-ROOT/WEB-INF/app/models/rule.rb:269:in `search'
              /tmp/sonar/tomcat6x/temp/0-ROOT/WEB-INF/app/controllers/rules_configuration_controller.rb:61:in `index'
      

        Issue Links

          Activity

          Hide
          Fabrice Bellingard added a comment -

          Fixed.
          And now, Sonar server startup fails if there's at least one rule that doesn't have a name or a description.

          Show
          Fabrice Bellingard added a comment - Fixed. And now, Sonar server startup fails if there's at least one rule that doesn't have a name or a description.
          Hide
          Fabrice Bellingard added a comment -

          IT added.

          Show
          Fabrice Bellingard added a comment - IT added.
          Hide
          Freddy Mallet added a comment -

          I'm waiting for SONAR-3343 before validating this ticket.

          Show
          Freddy Mallet added a comment - I'm waiting for SONAR-3343 before validating this ticket.
          Hide
          Freddy Mallet added a comment -

          Manually tested

          Show
          Freddy Mallet added a comment - Manually tested
          Hide
          Jeffrey Barrus added a comment -

          I am seeing this problem when using pluginflex. I can't see any commits that were made to alter the code referenced. How was this resolved? When I change the code to add a nil check, I no longer get the error.

          I am using version 3.2

          Show
          Jeffrey Barrus added a comment - I am seeing this problem when using pluginflex. I can't see any commits that were made to alter the code referenced. How was this resolved? When I change the code to add a nil check, I no longer get the error. I am using version 3.2
          Hide
          Freddy Mallet added a comment -

          Hi Jeffrey, I guess you're not using the latest version of the Sonar Flex Plugin ?

          Show
          Freddy Mallet added a comment - Hi Jeffrey, I guess you're not using the latest version of the Sonar Flex Plugin ?
          Hide
          Jeffrey Barrus added a comment -

          I built from the latest source.

          Show
          Jeffrey Barrus added a comment - I built from the latest source.
          Hide
          Freddy Mallet added a comment -

          Ok Jeffrey, and have you created and declared any new homemade Flex rules ?

          Show
          Freddy Mallet added a comment - Ok Jeffrey, and have you created and declared any new homemade Flex rules ?
          Hide
          Jeffrey Barrus added a comment -

          No I am only using the adobe rules (many of which have no description). I did a clean install of sonar 3.2 and the sonarflex 1.1 plugin. If I try to edit any of the rules, I get the null pointer exception. I have since made a custom build (https://github.com/jbarrus/sonar-flex I fixed a few issues with the sslr stuff in flex, which is really cool btw).

          Ihave been able to avoid this error by altering the rule note view:

          <% if rule.description != nil && rule.description.strip.start_with?('<p>') %>

          Show
          Jeffrey Barrus added a comment - No I am only using the adobe rules (many of which have no description). I did a clean install of sonar 3.2 and the sonarflex 1.1 plugin. If I try to edit any of the rules, I get the null pointer exception. I have since made a custom build ( https://github.com/jbarrus/sonar-flex I fixed a few issues with the sslr stuff in flex, which is really cool btw). Ihave been able to avoid this error by altering the rule note view: <% if rule.description != nil && rule.description.strip.start_with?('<p>') %>
          Hide
          Freddy Mallet added a comment -

          Hi Jeffrey, I can't manage to reproduce the issue with Sonar 3.2 and the Sonar Flex plugin 1.1. Starting from scratch, could you clearly describe the steps to reproduce the issue ? Thanks

          Show
          Freddy Mallet added a comment - Hi Jeffrey, I can't manage to reproduce the issue with Sonar 3.2 and the Sonar Flex plugin 1.1. Starting from scratch, could you clearly describe the steps to reproduce the issue ? Thanks
          Hide
          Jeffrey Barrus added a comment -

          Perhaps it has something to do with Oracle. You are right, when I setup sonar 3.2 with sonar flex 1.1 and use the h2 databse it works fine. When I use Oracle, I get the error.

          Do nulls get treated differently with the oracle activerecord implementation than the h2 one?

          Show
          Jeffrey Barrus added a comment - Perhaps it has something to do with Oracle. You are right, when I setup sonar 3.2 with sonar flex 1.1 and use the h2 databse it works fine. When I use Oracle, I get the error. Do nulls get treated differently with the oracle activerecord implementation than the h2 one?
          Hide
          Jeffrey Barrus added a comment -

          https://github.com/rails/rails/issues/7138

          I have very little experience with rails development, but this seems to be relevant and recent.

          Show
          Jeffrey Barrus added a comment - https://github.com/rails/rails/issues/7138 I have very little experience with rails development, but this seems to be relevant and recent.
          Hide
          Freddy Mallet added a comment -

          Problem reproduced Jeffrey, the ticket SONAR-3769 will be fixed in the next 3.3 Sonar version. Thanks for your feedback.

          Show
          Freddy Mallet added a comment - Problem reproduced Jeffrey, the ticket SONAR-3769 will be fixed in the next 3.3 Sonar version. Thanks for your feedback.

            People

            • Assignee:
              Fabrice Bellingard
              Reporter:
              Freddy Mallet
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: