haslo/lists_juggle_browser

View on GitHub

Showing 48 of 48 total issues

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

  def raw_ranking_configuration
    Hash[{
      large_tournament_multiplier:
        params['large_tournament_multiplier'].blank? || (params['large_tournament_multiplier'] == 'true')    ? nil : params['large_tournament_multiplier'],
      widespread_use_multiplier:
Severity: Minor
Found in app/controllers/application_controller.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 initialize has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def initialize(ranking_configuration, ship_id: nil, ship_combo_id: nil, pilot_id: nil, upgrade_id: nil, limit: nil)
      start_date      = ranking_configuration[:ranking_start]
      end_date        = ranking_configuration[:ranking_end]
      tournament_type = ranking_configuration[:tournament_type]
      joins           = <<-SQL
Severity: Major
Found in app/models/rankers/ship_combos_ranker.rb - About 2 hrs to fix

    Method initialize has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize(ranking_configuration, ship_id: nil, pilot_id: nil, limit: nil, upgrade_id: nil, ship_combo_id: nil)
          start_date      = ranking_configuration[:ranking_start]
          end_date        = ranking_configuration[:ranking_end]
          tournament_type = ranking_configuration[:tournament_type]
          joins           = <<-SQL
    Severity: Major
    Found in app/models/rankers/upgrades_ranker.rb - About 2 hrs to fix

      Method build_ranking_data has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def build_ranking_data(tournament_id)
            if (tournament_id.to_f / 50) == (tournament_id.to_i / 50)
              print "#{tournament_id}."
            else
              print '.'
      Severity: Minor
      Found in app/models/importers/ranking.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 sync_tournaments has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def sync_tournaments(minimum_id: nil, start_date: nil, add_missing: false)
            uri         = URI.parse('http://lists.starwarsclubhouse.com/api/v1/tournaments')
            response    = Net::HTTP.get_response(uri)
            tournaments = JSON.parse(response.body).try(:[], 'tournaments') || []
            tournaments.sort.each do |lists_juggler_id|
      Severity: Minor
      Found in app/models/importers/lists_juggler.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 initialize has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize(ranking_configuration, ship_id: nil, pilot_id: nil, ship_combo_id: nil, upgrade_id: nil)
            start_date      = ranking_configuration[:ranking_start]
            end_date        = ranking_configuration[:ranking_end]
            tournament_type = ranking_configuration[:tournament_type]
            joins           = <<-SQL
      Severity: Major
      Found in app/models/rankers/pilots_ranker.rb - About 2 hrs to fix

        Method initialize has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def initialize(ranking_configuration, ship_id: nil, ship_combo_id: nil, group_by_faction: false, faction_id: nil)
              start_date      = ranking_configuration[:ranking_start]
              end_date        = ranking_configuration[:ranking_end]
              tournament_type = ranking_configuration[:tournament_type]
              joins           = <<-SQL
        Severity: Major
        Found in app/models/rankers/ships_ranker.rb - About 2 hrs to fix

          Method initialize has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def initialize(ranking_configuration, ship_id: nil, pilot_id: nil, upgrade_id: nil, ship_combo_id: nil, limit: 2)
                start_date      = ranking_configuration[:ranking_start]
                end_date        = ranking_configuration[:ranking_end]
                tournament_type = ranking_configuration[:tournament_type]
                joins           = <<-SQL
          Severity: Minor
          Found in app/models/rankers/squadrons_ranker.rb - About 2 hrs to fix

            Method build_ranking_data has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def build_ranking_data(tournament_id)
                  if (tournament_id.to_f / 50) == (tournament_id.to_i / 50)
                    print "#{tournament_id}."
                  else
                    print '.'
            Severity: Minor
            Found in app/models/importers/ranking.rb - About 1 hr to fix

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

                  def build_weight_query
                    weight_query = case ranking_configuration[:use_ranking_data]
                                     when 'swiss'
                                       <<-SQL
                                      avg(
              Severity: Minor
              Found in app/models/rankers/weight_query_builder.rb - About 1 hr to fix

                Method sync_tournament has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def sync_tournament(tournament)
                      uri      = URI.parse("http://lists.starwarsclubhouse.com/api/v2/tournament/#{tournament.lists_juggler_id}")
                      response = Net::HTTP.get_response(uri)
                      begin
                        tournament_data  = JSON.parse(response.body).try(:[], 'tournament')
                Severity: Minor
                Found in app/models/importers/lists_juggler.rb - About 1 hr to fix

                  Method initialize has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def initialize(ranking_configuration, ship_combo_id)
                        start_date      = ranking_configuration[:ranking_start]
                        end_date        = ranking_configuration[:ranking_end]
                        tournament_type = ranking_configuration[:tournament_type]
                        joins           = <<-SQL
                  Severity: Minor
                  Found in app/models/rankers/counter_combo_ranker.rb - About 1 hr to fix

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

                      def ranking_configuration
                        {
                            large_tournament_multiplier: params['large_tournament_multiplier'].nil? ? true                 : (params['large_tournament_multiplier'] == 'true'),
                            widespread_use_multiplier:   params['widespread_use_multiplier'].nil?   ? true                 : (params['widespread_use_multiplier'] == 'true'),
                            use_ranking_data:            params['use_ranking_data'].nil?            ? 'all'                : params['use_ranking_data'],
                    Severity: Minor
                    Found in app/controllers/application_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 build_squadron has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def build_squadron(squadron_xws)
                            squadron_xws = JSON.parse(squadron_xws) if squadron_xws.is_a?(String)
                            faction_xws  = squadron_xws.try(:[], 'faction')
                            faction      = Faction.find_by(xws: faction_xws, is_subfaction: false)
                            squadron     = Squadron.new({
                    Severity: Minor
                    Found in app/models/importers/squadron_from_xws.rb - About 1 hr to fix

                      Method preset_dates has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def preset_dates
                          [
                            ['', nil],
                            [I18n.t('shared.filter_configurator.dates.wave_1'), Date.new(2012, 9, 14)],
                            [I18n.t('shared.filter_configurator.dates.wave_2'), Date.new(2013, 2, 28)],
                      Severity: Minor
                      Found in app/helpers/filter_helper.rb - About 1 hr to fix

                        Method generate_ship_combos has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                def generate_ship_combos(context, ship_combos, ships, ids = [])
                                  ::CSV.generate do |csv|
                                    csv << [
                                      context.t('ship_combos.csv.position'),
                                      context.t('ship_combos.csv.archetype_name'),
                        Severity: Minor
                        Found in app/models/generators/csv/ship_combos_generator.rb - About 1 hr to fix

                          Method update has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def update
                              ActiveRecord::Base.transaction do
                                suggestion = ArchetypeNameSuggestion.find(params[:id])
                                ship_combo = suggestion.ship_combo
                                case params[:mod_action]
                          Severity: Minor
                          Found in app/controllers/archetype_name_suggestions_controller.rb - About 1 hr to fix

                            Method build_win_loss_query has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def build_win_loss_query
                                  case ranking_configuration[:use_ranking_data]
                                    when 'swiss'
                                      <<-SQL
                                        avg(squadrons.win_loss_ratio_swiss)
                            Severity: Minor
                            Found in app/models/rankers/weight_query_builder.rb - About 1 hr to fix

                              Method generate_pilots has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      def generate_pilots(context, pilots, ids = [])
                                        ::CSV.generate do |csv|
                                          csv << [
                                            context.t('pilots.csv.position'),
                                            context.t('pilots.csv.pilot_name'),
                              Severity: Minor
                              Found in app/models/generators/csv/pilots_generator.rb - About 1 hr to fix

                                Method find_with_key has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                      def find_with_key(relation, key, faction_xws = nil)
                                        if faction_xws.present?
                                          model = relation.where(xws: key).where(faction_id: Faction.where(xws: faction_xws)).first
                                        else
                                          model = relation.find_by(xws: key)
                                Severity: Minor
                                Found in app/models/importers/squadron_from_xws.rb - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language