Uploaded image for project: 'Webservices REST Module'
  1. Webservices REST Module
  2. RESTWS-791 Search and fix minor errors
  3. RESTWS-796

Local variables should not be declared and then immediately returned

    XMLWordPrintable

    Details

    • Type: Sub-task
    • Status: Closed
    • Priority: Could
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.30.0
    • Labels:
    • Complexity:
      Low

      Description

      SonarQube:

      Declaring a variable only to immediately return or throw it is a bad practice.
      Some developers argue that the practice improves code readability, because it enables them to explicitly name what is being returned. However, this variable is an internal implementation detail that is not exposed to the callers of the method. The method name should be sufficient for callers to know exactly what will be returned.

      Problem:
      Create a variable only to return it from a method in the next step.

      Solution:
      Returning the result of a method, without unnecessary assigning to a variable.

      Where the problem occurs:

      Support materials:

        Gliffy Diagrams

          Attachments

            Activity

              People

              Assignee:
              kdaud Kakumirizi Daud
              Reporter:
              sacull Lukasz Debicki
              Designated Committer:
              Kakumirizi Daud Kakumirizi Daud
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 1 day Original Estimate - 1 day
                  1d
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 week
                  1w