snsavage/retro_casts

View on GitHub

Showing 9 of 9 total issues

Method has too many lines. [63/30]
Open

  def self.start(klass: RetroCasts::RailsCasts)
    retro_welcome
    welcome

    if !ARGV.empty?
Severity: Minor
Found in lib/retro_casts.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method start has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  def self.start(klass: RetroCasts::RailsCasts)
    retro_welcome
    welcome

    if !ARGV.empty?
Severity: Minor
Found in lib/retro_casts.rb - About 3 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

Cyclomatic complexity for start is too high. [15/6]
Open

  def self.start(klass: RetroCasts::RailsCasts)
    retro_welcome
    welcome

    if !ARGV.empty?
Severity: Minor
Found in lib/retro_casts.rb by rubocop

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.

Method start has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.start(klass: RetroCasts::RailsCasts)
    retro_welcome
    welcome

    if !ARGV.empty?
Severity: Major
Found in lib/retro_casts.rb - About 2 hrs to fix

    Cyclomatic complexity for build_url is too high. [7/6]
    Open

        def build_url
          attributes = {}
    
          attributes[:search] = search if search
          attributes[:page] = page if page != 1
    Severity: Minor
    Found in lib/retro_casts/rails_casts.rb by rubocop

    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.

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

        def build_url
          attributes = {}
    
          attributes[:search] = search if search
          attributes[:page] = page if page != 1
    Severity: Minor
    Found in lib/retro_casts/rails_casts.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 RetroCasts::Episode#date is defined at both lib/retro_casts/episode.rb:3 and lib/retro_casts/episode.rb:14.
    Open

        def date
    Severity: Minor
    Found in lib/retro_casts/episode.rb by rubocop

    This cop checks for duplicated instance (or singleton) method definitions.

    Example:

    # bad
    
    def duplicated
      1
    end
    
    def duplicated
      2
    end

    Example:

    # bad
    
    def duplicated
      1
    end
    
    alias duplicated other_duplicated

    Example:

    # good
    
    def duplicated
      1
    end
    
    def other_duplicated
      2
    end

    Useless private access modifier.
    Open

      private
    Severity: Minor
    Found in lib/retro_casts.rb by rubocop

    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

    Example:

    # Lint/UselessAccessModifier:
    #   MethodCreatingMethods:
    #     - delegate
    require 'active_support/core_ext/module/delegation'
    class Foo
      # this is not redundant because `delegate` creates methods
      private
    
      delegate :method_a, to: :method_b
    end

    Method RetroCasts::Episode#length is defined at both lib/retro_casts/episode.rb:3 and lib/retro_casts/episode.rb:18.
    Open

        def length
    Severity: Minor
    Found in lib/retro_casts/episode.rb by rubocop

    This cop checks for duplicated instance (or singleton) method definitions.

    Example:

    # bad
    
    def duplicated
      1
    end
    
    def duplicated
      2
    end

    Example:

    # bad
    
    def duplicated
      1
    end
    
    alias duplicated other_duplicated

    Example:

    # good
    
    def duplicated
      1
    end
    
    def other_duplicated
      2
    end
    Severity
    Category
    Status
    Source
    Language