sferik/twitter

View on GitHub

Showing 6 of 8 total issues

Method encode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def self.encode(data)
        data.collect do |k, v|
          if v.nil?
            ::URI::DEFAULT_PARSER.escape(k.to_s, UNESCAPED_CHARS)
          elsif v.respond_to?(:to_ary)
Severity: Minor
Found in lib/twitter/rest/form_encoder.rb - About 55 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def initialize(client, request_method, path, options = {}, params = nil)
Severity: Minor
Found in lib/twitter/rest/request.rb - About 35 mins to fix

    Method perform_request_with_object has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def perform_request_with_object(request_method, path, options, klass, params = nil)
    Severity: Minor
    Found in lib/twitter/rest/utils.rb - About 35 mins to fix

      Method parse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.parse(data) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
              if data[:id]
                Tweet.new(data)
              elsif data[:event]
                Event.new(data)
      Severity: Minor
      Found in lib/twitter/streaming/message_parser.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method merge_owner! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def merge_owner!(hash, user)
              return hash if hash[:owner_id] || hash[:owner_screen_name]
      
              if user
                merge_user!(hash, user, "owner")
      Severity: Minor
      Found in lib/twitter/rest/lists.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method request_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def request_options
              options = if @options_key == :form
                          {form: HTTP::FormData.create(@options, encoder: Twitter::REST::FormEncoder.method(:encode))}
                        else
                          {@options_key => @options}
      Severity: Minor
      Found in lib/twitter/rest/request.rb - About 25 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Severity
      Category
      Status
      Source
      Language