meissadia/tumblr_draftking

View on GitHub
lib/draftking/posts.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method some_posts has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def some_posts(before_id: 0, offset: 0, max_id: nil, since_id: nil)
      options = { limit: [(@limit || 50), 50].min }
      options[:max_id]   = max_id   if max_id
      options[:since_id] = since_id if since_id
      options[@source == :draft ? :before_id : :offset] =
Severity: Minor
Found in lib/draftking/posts.rb - About 2 hrs 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 auto_poster has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def auto_poster(options = {})
      process_options(options)
      act_on_blog(name: @blog_name)
      pprint "Retrieving posts...(can take a while for large queues)\r"
      posts = all_posts.reverse # FIFO
Severity: Minor
Found in lib/draftking/posts.rb - About 1 hr to fix

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

        def auto_poster(options = {})
          process_options(options)
          act_on_blog(name: @blog_name)
          pprint "Retrieving posts...(can take a while for large queues)\r"
          posts = all_posts.reverse # FIFO
    Severity: Minor
    Found in lib/draftking/posts.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 calculate_result has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def calculate_result(result_q)
          mod_count = 0
          mod_posts = []
          return [mod_count, mod_posts] if result_q.empty?
          while post = result_q.pop
    Severity: Minor
    Found in lib/draftking/posts.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

    There are no issues that match your filters.

    Category
    Status