100% free for Open Source, forever. Get another set of eyes on your code.

Take a look. Our new design is currently in beta, but you can start using it today!

8a494a9f
  • Cyclomatic complexity for textcaptcha is too high. [8/6]

    Cyclomatic complexity for textcaptcha is too high. [8/6]

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

          def textcaptcha
            if perform_textcaptcha? && textcaptcha_config
              question = answers = nil
    
              # get textcaptcha from api
    
    View more
  •       rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
            Errno::EHOSTUNREACH, EOFError, Errno::ECONNREFUSED, Errno::ETIMEDOUT,
            Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError,
            URI::InvalidURIError, ActsAsTextcaptcha::EmptyResponseError,
            REXML::ParseException
    
  • Useless private access modifier.

    Useless `private` access modifier.

    This cop checks for redundant access modifiers, including those with no code, those which are repeated, and leading public modifiers in a class or module body. Conditionally-defined methods are considered as always being defined, and thus access modifiers guarding such methods are not redundant.

    Example:

    class Foo
      public # this is redundant (default access is public)
    
      def method
      end
    
      private # this is not redundant (a method is defined)
      def method2
      end
    
      private # this is redundant (no following methods are defined)
    end
    

    Example:

    class Foo
      # The following is not redundant (conditionally defined methods are
      # considered as always defining a method)
      private
    
      if condition?
        def method
        end
      end
    
      protected # this is not redundant (method is defined)
    
      define_method(:method2) do
      end
    
      protected # this is redundant (repeated from previous modifier)
    
      [1,2,3].each do |i|
        define_method("foo#{i}") do
        end
      end
    
      # The following is redundant (methods defined on the class'
      # singleton class are not affected by the public modifier)
      public
    
      def self.method3
      end
    end
    

    Example:

    # Lint/UselessAccessModifier:
    #   ContextCreatingMethods:
    #     - concerning
    require 'active_support/concern'
    class Foo
      concerning :Bar do
        def some_public_method
        end
    
        private
    
        def some_private_method
        end
      end
    
      # this is not redundant because `concerning` created its own context
      private
    
      def some_other_private_method
      end
    end
    
        private
    
  • Previous Page
    Next Page