Uploaded image for project: 'SonarSlang'
  1. SonarSlang
  2. SONARSLANG-519

[Ruby] S1172 does not work when the file has more than one function

    XMLWordPrintable

    Details

    • Type: False Negative
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8
    • Component/s: Ruby
    • Labels:
      None

      Description

      The existing rule UnusedFunctionParameter S1172 does not work for Ruby code.

      The rule raises on methods that are either:

      • under TopLevelTree (not in a class) - but for ruby, the parent of the context of a top-level function is a Block, not a TopLevelTree (except when the function is the only piece of code in the file)
      • a private class method, but in ruby the modifier doesn't seem to get in the tree
      def is_not_used( a )
        puts "Hello, World!" # FN
      end
      
      class Foo
          private def is_not_used( a )
            puts "Hello, World!" # FN
          end
      end
      
      class Bar
      
          private
      
          def is_not_used( a )
            puts "Hello, World!" # FN
          end
      end
      
      

      Note: the rule works only if the function is the only piece of code in the file

      def foo(unused)
        puts 'Hello' # Noncompliant
      end
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              andrei.epure Andrei Epure
              Reporter:
              andrei.epure Andrei Epure
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Due:
                Created:
                Updated:
                Resolved: