Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-3782

Arguments to built-in functions should match documented types

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
      None
    • Message:
      Verify that argument is of correct type: xxx instead of yyy.
    • Highlighting:
      Hide

      Argument

      Show
      Argument
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way, Sonar way recommended
    • Covered Languages:
      JavaScript
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • Analysis Scope:
      Main Sources, Test Sources

      Description

      The types of the arguments to built-in functions are specified in the JavaScript language specifications. Calls to these functions should conform to the documented types, otherwise the result will most likely not be what was expected (e.g.: the call would always return false).

      Noncompliant Code Example

      const isTooSmall = Math.abs(x < 0.0042);
      

      Compliant Solution

      const isTooSmall = Math.abs(x) < 0.0042;
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jeanchristophe.collet Jean-Christophe Collet (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: