meissadia/tumblr_draftking

View on GitHub

Showing 22 of 22 total issues

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 uploads has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def uploads
      configured?
      opts   = process_options(options)
      dk     = get_dk_instance(opts)
      dfile  = opts[:file].chomp.strip
Severity: Minor
Found in lib/draftking/cli/commands/uploads.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 generate_toc has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def generate_toc(filename)
  data = read_file(filename)
  base = 2
  indent = [0]
  last = base
Severity: Minor
Found in readme/generate.rb - About 1 hr 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 save has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def save(client:, simulate: nil)
      return 0 unless @changed
      return @saved = 1 if simulate
      retries = 0
      begin
Severity: Minor
Found in lib/draftking/posts/post.rb - About 1 hr 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 save_file has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def self.save_file(config:, account: '', mute: false, filename: nil)
      account = '.' + account unless account.empty?
      path = filename || home_path_file(account + DK::CONFIG_FILENAME)
      File.open(path, 'w') { |f| f.write YAML.dump config.to_h }
      puts "\nConfiguration saved to #{path} #{'(Default)' if account.empty?}" unless mute
Severity: Minor
Found in lib/draftking/config.rb - About 1 hr 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 drafts_to_queue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def drafts_to_queue(options = {})
      options[:message] = 'Moving Drafts -> Queue: '
      options[:shuffle] = true
      options[:state]   = DK::QUEUE
      post_operation(options) do |post, index|
Severity: Minor
Found in lib/draftking/drafts.rb - About 1 hr 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 act_on_blog has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def act_on_blog(name: nil)
          return unless connected?
          @user = client_user_info_to_ostruct
          @blog_name = name ? name.gsub('.tumblr.com', '') : @user.blogs.first.name
          @blog_url  = tumblr_url(@blog_name)
    Severity: Minor
    Found in lib/draftking/client.rb - About 45 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 process_source has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_source(src)
          return :draft unless src
          return src if src.is_a? Symbol
          return :dashboard if src.include?('dash')
          return :queue if src.include?('queue')
    Severity: Minor
    Found in lib/draftking/client.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 build_rows has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_rows(dk)
          dk.user.blogs.map do |b|
            next unless blog.nil? || b.name == blog
            [b.name, b.drafts, b.queue, 300 - b.queue.to_i]
          end.compact
    Severity: Minor
    Found in lib/draftking/cli/commands/status.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 show_progress has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def show_progress(current: 0, total: 0, message: '', done: false, modified: 0)
          return unless @show_pi
          indicator, newline, progress = setup_done(modified) if done
          indicator, newline, progress = setup_undone(current, total) unless done
          pprint "#{indicator}#{message}#{progress}#{' ' * 30}\r#{newline}"
    Severity: Minor
    Found in lib/draftking/posts/posts_helpers.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 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

    Avoid too many return statements within this method.
    Open

          return :posts if src.include?('publish')
    Severity: Major
    Found in lib/draftking/client.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return :draft if src.include?('draft')
      Severity: Major
      Found in lib/draftking/client.rb - About 30 mins to fix

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

            def config_to_num(input)
              return nil if input.nil? || DK::Config.available_configs.empty?
              case input
              when /^\d+$/.match(input) # Numeric String
                return input
        Severity: Minor
        Found in lib/draftking/cli/cli_helpers.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

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

            def process_options(options)
              opts = options.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v; memo }
              opts[:blog_name] = options[:blog] if options[:blog]
              opts[:keep_tree] = options[:keep_comments] if options[:keep_comments]
              opts[:source]    = process_source(options[:source])
        Severity: Minor
        Found in lib/draftking/cli/cli_helpers.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

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

            def generate_tags(keep_tags: nil, add_tags: nil, exclude: nil, credit: false)
              tags  = comment_to_tags(@comment)
              tags += csv_to_a(add_tags)    if add_tags
              tags += @tags                 if keep_tags
              tags << DK::CREDIT_TAG        if credit
        Severity: Minor
        Found in lib/draftking/posts/post.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

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

            def self.validate_keys(api_keys)
              return nil if api_keys.nil?
              return nil unless api_keys.respond_to?(:keys)
              return {}  unless api_keys.keys.all? { |k| VALID_KEYS.include?(k.to_s) }
              return {}  if api_keys.values.include?(nil)
        Severity: Minor
        Found in lib/draftking/config.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

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

            def reblog(client:, simulate: nil)
              return 1 if simulate
              retries = 0
              begin
                client.reblog @blog_url,
        Severity: Minor
        Found in lib/draftking/posts/post.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