hummingbird-me/kitsu-server

View on GitHub

Showing 165 of 166 total issues

File rails_admin.rb has 477 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require Rails.root.join('lib/rails_admin/config/fields/types/localized_string')
require Rails.root.join('lib/rails_admin/config/fields/types/localized_text')
require Rails.root.join('lib/rails_admin/config/fields/types/string_list')
require Rails.root.join('lib/rails_admin/config/fields/types/flags')
require Rails.root.join('lib/rails_admin/config/fields/types/duration')
Severity: Minor
Found in config/initializers/rails_admin.rb - About 7 hrs to fix

    Method preload_included_fragments has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        def preload_included_fragments(resources, records, serializer, options)
          return if resources.empty?
          res_ids = resources.keys
    
          include_directives = options[:include_directives]
    Severity: Minor
    Found in app/resources/concerns/ignore_preloading_nils.rb - About 4 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 object_hash has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

      def object_hash(source, include_directives = {})
        obj_hash = {}
    
        if source.is_a?(JSONAPI::CachedResourceFragment)
          if source.class.name != 'CategoryRecommendationResource'
    Severity: Minor
    Found in app/serializers/category_recommendation_serializer.rb - About 4 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

    Class User has 33 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class User < ApplicationRecord
      include AvatarUploader::Attachment(:avatar)
      include CoverImageUploader::Attachment(:cover_image)
    
      PAST_NAMES_LIMIT = 10
    Severity: Minor
    Found in app/models/user.rb - About 4 hrs to fix

      File user.rb has 309 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class User < ApplicationRecord
        include AvatarUploader::Attachment(:avatar)
        include CoverImageUploader::Attachment(:cover_image)
      
        PAST_NAMES_LIMIT = 10
      Severity: Minor
      Found in app/models/user.rb - About 3 hrs to fix

        Method preload_included_fragments has 83 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def preload_included_fragments(resources, records, serializer, options)
              return if resources.empty?
              res_ids = resources.keys
        
              include_directives = options[:include_directives]
        Severity: Major
        Found in app/resources/concerns/ignore_preloading_nils.rb - About 3 hrs to fix

          Method apply_selects has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

                def apply_selects(activities, selects, grouped = false)
                  return activities if selects.empty?
                  # We use map+reject(blank) so that we can modify the activities in the
                  # groups
                  activities = activities.lazy.map do |act|
          Severity: Minor
          Found in app/models/feed/activity_list/page.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

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

          class PortraitImageUploader < Shrine
            include ImageUploader
            include PublicUploader
          
            DERIVATIVES = {
          Severity: Major
          Found in app/uploaders/portrait_image_uploader.rb and 2 other locations - About 2 hrs to fix
          app/uploaders/poster_image_uploader.rb on lines 3..25
          app/uploaders/unit_thumbnail_uploader.rb on lines 3..25

          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 94.

          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 3 locations. Consider refactoring.
          Open

          class UnitThumbnailUploader < Shrine
            include ImageUploader
            include PublicUploader
          
            DERIVATIVES = {
          Severity: Major
          Found in app/uploaders/unit_thumbnail_uploader.rb and 2 other locations - About 2 hrs to fix
          app/uploaders/portrait_image_uploader.rb on lines 3..25
          app/uploaders/poster_image_uploader.rb on lines 3..25

          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 94.

          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 3 locations. Consider refactoring.
          Open

          class PosterImageUploader < Shrine
            include ImageUploader
            include PublicUploader
          
            DERIVATIVES = {
          Severity: Major
          Found in app/uploaders/poster_image_uploader.rb and 2 other locations - About 2 hrs to fix
          app/uploaders/portrait_image_uploader.rb on lines 3..25
          app/uploaders/unit_thumbnail_uploader.rb on lines 3..25

          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 94.

          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

          Class Row has 23 methods (exceeds 20 allowed). Consider refactoring.
          Open

              class Row
                def initialize(node, type)
                  @node = node
                  @type = type.to_s.downcase # anime | manga
                end
          Severity: Minor
          Found in app/models/list_import/anilist/row.rb - About 2 hrs to fix

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

                def pluck_arel_attributes(relation, *attrs)
                  if relation.is_a?(Chewy::Query)
                    attr_names = attrs.map { |a| a.name.to_s }
                    relation = relation.only(*attr_names)
                    relation.map { |row| row.attributes.values_at(*attr_names) }
            Severity: Major
            Found in app/resources/concerns/searchable_resource.rb and 1 other location - About 2 hrs to fix
            app/resources/concerns/algolia_searchable_resource.rb on lines 103..119

            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 89.

            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

                def pluck_arel_attributes(relation, *attrs)
                  if relation.is_a?(Chewy::Query)
                    attr_names = attrs.map { |a| a.name.to_s }
                    relation = relation.only(*attr_names)
                    relation.map { |row| row.attributes.values_at(*attr_names) }
            Severity: Major
            Found in app/resources/concerns/algolia_searchable_resource.rb and 1 other location - About 2 hrs to fix
            app/resources/concerns/searchable_resource.rb on lines 110..126

            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 89.

            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

            Method associate_initial_anime! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def associate_initial_anime!
                  exclude_ids = []
                  puts 'Associating Anime With Categories From AniDB Dump'
                  data.each do |unfiltered_anime|
                    unfiltered_anime = unfiltered_anime.deep_symbolize_keys
            Severity: Minor
            Found in lib/anidb_category_import/media_importer.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

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

                def auto_query(field, value)
                  case value
                  when String, Integer, Float, Date
                    { match: { field => value } }
                  when Range
            Severity: Major
            Found in app/resources/concerns/searchable_resource.rb and 1 other location - About 2 hrs to fix
            app/resources/concerns/algolia_searchable_resource.rb on lines 178..195

            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 78.

            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

                def auto_query(field, value)
                  case value
                  when String, Integer, Float, Date
                    { match: { field => value } }
                  when Range
            Severity: Major
            Found in app/resources/concerns/algolia_searchable_resource.rb and 1 other location - About 2 hrs to fix
            app/resources/concerns/searchable_resource.rb on lines 185..202

            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 78.

            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

            Method auto_query has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def auto_query(field, value)
                  case value
                  when String, Integer, Float, Date
                    { match: { field => value } }
                  when Range
            Severity: Minor
            Found in app/resources/concerns/algolia_searchable_resource.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_query has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def auto_query(field, value)
                  case value
                  when String, Integer, Float, Date
                    { match: { field => value } }
                  when Range
            Severity: Minor
            Found in app/resources/concerns/searchable_resource.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 stats_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def stats_data
                  data = super || default_data
                  # Generate percentile data
                  if global_stat
                    data['percentiles'] = %w[media units time].each_with_object({}) do |key, out|
            Severity: Minor
            Found in app/models/concerns/stat/amount_consumed.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 apply_scopes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def apply_scopes(filters, opts = {})
                  context = opts[:context]
                  if _search_service
                    # Separate queries from filters
                    queries = filters.select { |f| @_query_fields.include?(f) }
            Severity: Minor
            Found in app/resources/concerns/searchable_resource.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

            Severity
            Category
            Status
            Source
            Language