awkisopen/australium

View on GitHub

Showing 11 of 11 total issues

Method initialize_clone has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def initialize_clone(other)
    super
    self.each_pair do |key, value|
      if value.is_a?(OpenStruct)
        self[key] = value.clone
Severity: Minor
Found in lib/australium/ref/open_struct_deep_clone.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 parse_line has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def self.parse_line(line, line_number, state = nil)
      Event::event_classes.each do |event_class|
        next unless defined?(event_class::LOG_REGEX)
        if event_class::LOG_REGEX =~ line
          # Get timestamp data & timestamp GameState if we are being stateful
Severity: Minor
Found in lib/australium/parser.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 hash_to_obj has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def hash_to_obj(hash)
      hash.each_pair do |key, value|
        hash[key] = hash_to_obj(value) if value.is_a?(Hash)
        hash[key] = value.map { |x| hash_to_obj(x) if x.is_a?(Hash) } if value.is_a?(Array)
      end
Severity: Minor
Found in lib/australium/cache/event_cache.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 obj_to_hash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def obj_to_hash(obj)
      obj.each_pair do |key, value|
        obj[key] = obj_to_hash(value) if value.is_a?(OpenStruct)
        obj[key] = value.map { |x| obj_to_hash(x) if x.is_a?(OpenStruct) } if value.is_a?(Array)
      end
Severity: Minor
Found in lib/australium/cache/event_cache.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 store has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def store(game)

      # If a MapLoad event exists with identical parameters for everything except the game hash, delete the previous
      # game data - as this indicates an invalid or incomplete log was stored.
      start_event = game.map_loads.first
Severity: Minor
Found in lib/australium/cache/event_cache.rb - About 1 hr to fix

    Method initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(data)
          super(data)
    
          # Replace anything matching a Player string with a Player object.
          self.each_pair do |key, value|
    Severity: Minor
    Found in lib/australium/event.rb - About 55 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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(data)
          super(data)
    
          unless self.state.nil? || self.state.players.nil?
            self.state.players.each do |player|
    Severity: Minor
    Found in lib/australium/events/game_end.rb - About 55 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 store has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def store(game)
    
          # If a MapLoad event exists with identical parameters for everything except the game hash, delete the previous
          # game data - as this indicates an invalid or incomplete log was stored.
          start_event = game.map_loads.first
    Severity: Minor
    Found in lib/australium/cache/event_cache.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 parse_game_log has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.parse_game_log(lines, properties = {})
          state = GameState.new
          state.game_id = game_log_digest(lines)
          events = []
    
    
    Severity: Minor
    Found in lib/australium/parser.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

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

          hash.each_pair do |key, value|
            hash[key] = hash_to_obj(value) if value.is_a?(Hash)
            hash[key] = value.map { |x| hash_to_obj(x) if x.is_a?(Hash) } if value.is_a?(Array)
    Severity: Minor
    Found in lib/australium/cache/event_cache.rb and 1 other location - About 25 mins to fix
    lib/australium/cache/event_cache.rb on lines 68..70

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

    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

          obj.each_pair do |key, value|
            obj[key] = obj_to_hash(value) if value.is_a?(OpenStruct)
            obj[key] = value.map { |x| obj_to_hash(x) if x.is_a?(OpenStruct) } if value.is_a?(Array)
    Severity: Minor
    Found in lib/australium/cache/event_cache.rb and 1 other location - About 25 mins to fix
    lib/australium/cache/event_cache.rb on lines 52..54

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

    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

    Severity
    Category
    Status
    Source
    Language