nabeelamjad/poke-api

View on GitHub

Showing 71 of 71 total issues

Block has too many lines. [47/25]
Open

Google::Protobuf::DescriptorPool.generated_pool.build do
  add_message "POGOProtos.Settings.Master.Item.PokeballAttributes" do
    optional :item_effect, :enum, 1, "POGOProtos.Enums.ItemEffect"
    optional :capture_multi, :float, 2
    optional :capture_multi_effect, :float, 3

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Block has too many lines. [45/25]
Open

Google::Protobuf::DescriptorPool.generated_pool.build do
  add_message "POGOProtos.Settings.MapSettings" do
    optional :pokemon_visible_range, :double, 1
    optional :poke_nav_range_meters, :double, 2
    optional :encounter_range_meters, :double, 3

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

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

        def level
          return MAX_LEVEL if leaf?

          x = (@id & 0xffffffff)
          level = -1
Severity: Minor
Found in lib/poke-api/geometry/s2_cell_id.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.

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

        def self.valid_face_xyz_to_uv(face, p)
          raise unless p.dot_prod(face_uv_to_xyz(face, 0, 0)) > 0

          case face
          when 0 then [p.y / p.x, p.z / p.x]
Severity: Minor
Found in lib/poke-api/geometry/s2_cell_id.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 find_poi has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def find_poi(client, lat, lng)
  step_size = 0.0015
  step_limit = 49

  coords = generate_spiral(lat, lng, step_size, step_limit)
Severity: Minor
Found in examples/spiral_search.rb - About 1 hr to fix

    Block has too many lines. [38/25]
    Open

      add_enum "POGOProtos.Enums.BadgeType" do
        value :BADGE_UNSET, 0
        value :BADGE_TRAVEL_KM, 1
        value :BADGE_POKEDEX_ENTRIES, 2
        value :BADGE_CAPTURE_TOTAL, 3

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

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

          def parse_rpc_fields(responses)
            responses.map! do |x|
              x = x.to_hash if x.class.name =~ /POGOProtos/
              x
            end if responses.is_a?(Array)
    Severity: Minor
    Found in lib/poke-api/response.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

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

    module POGOProtos
      module Settings
        MapSettings = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Settings.MapSettings").msgclass
        FortSettings = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Settings.FortSettings").msgclass
        GpsSettings = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Settings.GpsSettings").msgclass
    Severity: Major
    Found in lib/poke-api/pogoprotos/pogoprotos_settings.rb and 1 other location - About 1 hr to fix
    lib/poke-api/pogoprotos/pogoprotos_map_fort.rb on lines 60..68

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

    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

      module Map
        module Fort
          FortSummary = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Map.Fort.FortSummary").msgclass
          FortModifier = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Map.Fort.FortModifier").msgclass
          FortData = Google::Protobuf::DescriptorPool.generated_pool.lookup("POGOProtos.Map.Fort.FortData").msgclass
    Severity: Major
    Found in lib/poke-api/pogoprotos/pogoprotos_map_fort.rb and 1 other location - About 1 hr to fix
    lib/poke-api/pogoprotos/pogoprotos_settings.rb on lines 54..62

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

    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

        while 2 * y * d < m && steps < step_limit
          y += d
          steps += 1
          lat = x * step_size + starting_lat + rand * ((rlow - rhigh) + rlow)
          lng = y * step_size + starting_lng + rand * ((rlow - rhigh) + rlow)
    Severity: Major
    Found in examples/spiral_search.rb and 1 other location - About 1 hr to fix
    examples/spiral_search.rb on lines 15..21

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

    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

        while 2 * x * d < m && steps < step_limit
          x += d
          steps += 1
          lat = x * step_size + starting_lat + rand * ((rlow - rhigh) + rlow)
          lng = y * step_size + starting_lng + rand * ((rlow - rhigh) + rlow)
    Severity: Major
    Found in examples/spiral_search.rb and 1 other location - About 1 hr to fix
    examples/spiral_search.rb on lines 22..28

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

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

            def level
              return MAX_LEVEL if leaf?
    
              x = (@id & 0xffffffff)
              level = -1
    Severity: Minor
    Found in lib/poke-api/geometry/s2_cell_id.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 generate_spiral has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def generate_spiral(starting_lat, starting_lng, step_size, step_limit)
      coords = [{ lat: starting_lat, lng: starting_lng }]
      steps = 1
      x = 0
      y = 0
    Severity: Minor
    Found in examples/spiral_search.rb - About 1 hr to fix

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

        add_enum "POGOProtos.Networking.Responses.StartGymBattleResponse.Result" do
          value :UNSET, 0
          value :SUCCESS, 1
          value :ERROR_GYM_NOT_FOUND, 2
          value :ERROR_GYM_NEUTRAL, 3
      Severity: Minor
      Found in lib/poke-api/pogoprotos/pogoprotos_networking_responses.rb and 1 other location - About 55 mins to fix
      lib/poke-api/pogoprotos/pogoprotos_enums.rb on lines 298..312

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

      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

        add_enum "POGOProtos.Enums.CameraTarget" do
          value :CAM_TARGET_ATTACKER, 0
          value :CAM_TARGET_ATTACKER_EDGE, 1
          value :CAM_TARGET_ATTACKER_GROUND, 2
          value :CAM_TARGET_DEFENDER, 3
      Severity: Minor
      Found in lib/poke-api/pogoprotos/pogoprotos_enums.rb and 1 other location - About 55 mins to fix
      lib/poke-api/pogoprotos/pogoprotos_networking_responses.rb on lines 206..220

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

      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

      Block has too many lines. [31/25]
      Open

        coords.each do |coord|
          lat = coord[:lat]
          lng = coord[:lng]
          client.store_lat_lng(lat, lng)
      
      
      Severity: Minor
      Found in examples/spiral_search.rb by rubocop

      This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

      Method lookup_cells has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def self.lookup_cells(level, i, j, orig_orientation, pos, orientation)
      Severity: Minor
      Found in lib/poke-api/geometry/s2_base.rb - About 45 mins to fix

        Block has too many lines. [30/25]
        Open

        Google::Protobuf::DescriptorPool.generated_pool.build do
          add_message "POGOProtos.Data.Logs.ActionLogEntry" do
            optional :timestamp_ms, :int64, 1
            optional :sfida, :bool, 2
            oneof :Action do

        This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

        Block has too many lines. [30/25]
        Open

          add_message "POGOProtos.Data.PokemonData" do
            optional :id, :fixed64, 1
            optional :pokemon_id, :enum, 2, "POGOProtos.Enums.PokemonId"
            optional :cp, :int32, 3
            optional :stamina, :int32, 4

        This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

        Block has too many lines. [30/25]
        Open

          add_enum "POGOProtos.Inventory.Item.ItemId" do
            value :ITEM_UNKNOWN, 0
            value :ITEM_POKE_BALL, 1
            value :ITEM_GREAT_BALL, 2
            value :ITEM_ULTRA_BALL, 3

        This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

        Severity
        Category
        Status
        Source
        Language