Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.3
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      function fun(a, b) { // "b" unused
        print(a);
      }
      

        Issue Links

          Activity

          Hide
          Evgeny Mandrikov added a comment -

          Integration tests were updated.

          Show
          Evgeny Mandrikov added a comment - Integration tests were updated.
          Hide
          Freddy Mallet added a comment -

          Works well Evgeny, could you just update the description :

          An unused function argument is a kind of dead code. Such unused argument should be removed to increase the maintainability of a javascript program.

          The following code snippet illustrates this rule :

          function fun(a, b) { // Non-Compliant as 'a' argument is not used  
            var result = b/3;
            return b;
          }
          
          Show
          Freddy Mallet added a comment - Works well Evgeny, could you just update the description : An unused function argument is a kind of dead code. Such unused argument should be removed to increase the maintainability of a javascript program. The following code snippet illustrates this rule : function fun(a, b) { // Non-Compliant as 'a' argument is not used var result = b/3; return b; }
          Hide
          Evgeny Mandrikov added a comment -

          Done.

          Show
          Evgeny Mandrikov added a comment - Done.
          Hide
          Freddy Mallet added a comment -

          Manually tested !

          Show
          Freddy Mallet added a comment - Manually tested !
          Hide
          SteveB added a comment -

          JSHint does not report unused function arguments when followed by an used argument http://www.jshint.com/docs/options/#unused

          Without this behavior it is nearly impossible to write function callbacks against popular APIs, such as jquery, knockout etc.

          E.g. jquery has the 'each' helper to iterate over arrays or objects. If only the value is used it will report an unused argument 'i'

          $(["first", "last"]).each(function (i, value) {
            computeSomethingWithValue(value);
          });
          

          More examples on nemo http://nemo.sonarqube.org/drilldown/issues/420506?&rule=javascript%3AUnusedFunctionArgument&rule_sev=MAJOR&severity=MAJOR

          Show
          SteveB added a comment - JSHint does not report unused function arguments when followed by an used argument http://www.jshint.com/docs/options/#unused Without this behavior it is nearly impossible to write function callbacks against popular APIs, such as jquery, knockout etc. E.g. jquery has the 'each' helper to iterate over arrays or objects. If only the value is used it will report an unused argument 'i' $([ "first" , "last" ]).each(function (i, value) { computeSomethingWithValue(value); }); More examples on nemo http://nemo.sonarqube.org/drilldown/issues/420506?&rule=javascript%3AUnusedFunctionArgument&rule_sev=MAJOR&severity=MAJOR
          Hide
          Linda Martin added a comment -

          @SteveB indeed, ticket has been created to restrict triggered issue to dangling unused function arguments: SONARPLUGINS-335
          Thanks for your feedback.

          Show
          Linda Martin added a comment - @SteveB indeed, ticket has been created to restrict triggered issue to dangling unused function arguments: SONARPLUGINS-335 Thanks for your feedback.

            People

            • Assignee:
              Evgeny Mandrikov
              Reporter:
              Evgeny Mandrikov
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: