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

    • Sub-task
    • Status: Closed
    • Could
    • Resolution: Fixed
    • None
    • 2.30.0
    • None
    • 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

              kdaud Kakumirizi Daud
              sacull Lukasz Debicki
              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