hummingbird-me/hummingbird

View on GitHub
app/controllers/anime_controller.rb

Summary

Maintainability
F
3 days
Test Coverage

Method filter_new has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

  def filter_new
    @filter_years = %w(Upcoming 2010s 2000s 1990s 1980s 1970s Older)

    respond_to do |format|
      format.html do
Severity: Minor
Found in app/controllers/anime_controller.rb - About 6 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 filter_old has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def filter_old
    hide_cover_image
    @filter_years = %w(Upcoming 2010s 2000s 1990s 1980s 1970s Older)

    if params[:g]
Severity: Minor
Found in app/controllers/anime_controller.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

Method filter_new has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def filter_new
    @filter_years = %w(Upcoming 2010s 2000s 1990s 1980s 1970s Older)

    respond_to do |format|
      format.html do
Severity: Major
Found in app/controllers/anime_controller.rb - About 2 hrs to fix

    Method filter_old has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def filter_old
        hide_cover_image
        @filter_years = %w(Upcoming 2010s 2000s 1990s 1980s 1970s Older)
    
        if params[:g]
    Severity: Major
    Found in app/controllers/anime_controller.rb - About 2 hrs to fix

      Method upcoming has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def upcoming
          hide_cover_image
      
          season_months = {
            'winter' => [12, 1, 2],
      Severity: Minor
      Found in app/controllers/anime_controller.rb - About 1 hr to fix

        Method upcoming has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def upcoming
            hide_cover_image
        
            season_months = {
              'winter' => [12, 1, 2],
        Severity: Minor
        Found in app/controllers/anime_controller.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 index has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def index
            respond_to do |format|
              format.html do
                hide_cover_image
                @filter_years = %w(Upcoming 2010s 2000s 1990s 1980s 1970s Older)
        Severity: Minor
        Found in app/controllers/anime_controller.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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                if @years.length != @filter_years.length
                  filter_year_ranges = {
                    '2010s' => Date.new(2010, 1, 1)..Date.new(2020, 1, 1),
                    '2000s' => Date.new(2000, 1, 1)..Date.new(2010, 1, 1),
                    '1990s' => Date.new(1990, 1, 1)..Date.new(2000, 1, 1),
        Severity: Major
        Found in app/controllers/anime_controller.rb and 1 other location - About 4 hrs to fix
        app/controllers/anime_controller.rb on lines 138..165

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 157.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            if @years.length != @filter_years.length
              filter_year_ranges = {
                '2010s' => Date.new(2010, 1, 1)..Date.new(2020, 1, 1),
                '2000s' => Date.new(2000, 1, 1)..Date.new(2010, 1, 1),
                '1990s' => Date.new(1990, 1, 1)..Date.new(2000, 1, 1),
        Severity: Major
        Found in app/controllers/anime_controller.rb and 1 other location - About 4 hrs to fix
        app/controllers/anime_controller.rb on lines 226..253

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 157.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            if @sort == 'newest'
              @anime = @anime.order('started_airing_date DESC')
            elsif @sort == 'oldest'
              @anime = @anime.order('started_airing_date')
            elsif @sort == 'popular'
        Severity: Minor
        Found in app/controllers/anime_controller.rb and 1 other location - About 25 mins to fix
        app/controllers/anime_controller.rb on lines 214..223

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 30.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                if @sort == 'newest'
                  @anime = @anime.order('started_airing_date DESC')
                elsif @sort == 'oldest'
                  @anime = @anime.order('started_airing_date')
                elsif @sort == 'popular'
        Severity: Minor
        Found in app/controllers/anime_controller.rb and 1 other location - About 25 mins to fix
        app/controllers/anime_controller.rb on lines 126..135

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 30.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                if params[:sort_by] && params[:sort_by].in?(sort_options)
                  reverse = (params[:sort_reverse].nil?) ? '' : ' DESC NULLS LAST'
                  anime = Anime.order(params[:sort_by] + reverse)
                end
        Severity: Minor
        Found in app/controllers/anime_controller.rb and 1 other location - About 20 mins to fix
        app/controllers/manga_controller.rb on lines 26..29

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 27.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        There are no issues that match your filters.

        Category
        Status