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

Return values from functions without side effects should not be ignored

    XMLWordPrintable

    Details

    • Type: Bug Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      The return value of "[method name]" must be used.
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Targeted languages:
      C, C++, Flex, HTML, Objective-C, VB.Net
    • Covered Languages:
      C#, Java, JavaScript, PHP, Python, Swift, TypeScript
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      10min
    • Analysis Level:
      Abstract Interpretation
    • Analysis Scope:
      Main Sources
    • Common Rule:
      Yes
    • CERT:
      EXP12-C., EXP00-J.
    • MISRA C 2012:
      17.7
    • CPPCheck:
      ignoredReturnValue, leakReturnValNotUsed, uselessCallsRemove, uselessCallsEmpty
    • FindBugs:
      RV_RETURN_VALUE_IGNORED, RV_RETURN_VALUE_IGNORED_INFERRED, RV_RETURN_VALUE_IGNORED2, RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT, RV_RETURN_VALUE_OF_PUTIFABSENT_IGNORED, RV_RETURN_VALUE_IGNORED_BAD_PRACTICE
    • FxCop:
      DoNotIgnoreMethodResults, CA1806
    • PMD:
      UselessOperationOnImmutable
    • ReSharper:
      IteratorMethodResultIsIgnored, ReturnValueOfPureMethodIsNotUsed
    • TSLint-SonarTS:
      no-ignored-return

      Description

      When the call to a function doesn't have any side effect, what is the point of making the call if the results are ignored? In such cases, either the function call is useless and should be dropped, or the source code doesn't behave as expected.

      See

        Attachments

          Issue Links

          1.
          Java RSPEC-2246 Language-Specification Active Unassigned
          2.
          C-Family RSPEC-2247 Language-Specification Active Unassigned
          3.
          C# RSPEC-3448 Language-Specification Active Unassigned
          4.
          JavaScript RSPEC-3784 Language-Specification Active Unassigned
          5.
          Swift RSPEC-4218 Language-Specification Active Unassigned
          6.
          PHP RSPEC-4314 Language-Specification Active Unassigned
          7.
          Python RSPEC-5784 Language-Specification Active Unassigned

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              ann.campbell.2 Ann Campbell
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: