sferik/twitter

View on GitHub

Showing 4 of 4 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 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 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