OpenC3/cosmos

View on GitHub
openc3/lib/openc3/packets/json_packet.rb

Summary

Maintainability
C
1 day
Test Coverage

Method read has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def read(name, value_type = :CONVERTED, reduced_type = nil)
      value = nil
      array_index = nil
      # Check for array index to handle array items but also make sure there
      # isn't a REAL item that has brackets in the name
Severity: Major
Found in openc3/lib/openc3/packets/json_packet.rb - About 3 hrs to fix

    Method read_all_names has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def read_all_names(value_type = nil, reduced_type = nil)
          result = {}
          if value_type
            case value_type
            when :RAW
    Severity: Minor
    Found in openc3/lib/openc3/packets/json_packet.rb - About 1 hr to fix

      Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(cmd_or_tlm, target_name, packet_name, time_nsec_since_epoch, stored, json_data, key_map = nil, received_time_nsec_since_epoch: nil, extra: nil)
      Severity: Major
      Found in openc3/lib/openc3/packets/json_packet.rb - About 50 mins to fix

        Avoid too many return statements within this method.
        Open

                  return value.to_s
        Severity: Major
        Found in openc3/lib/openc3/packets/json_packet.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                    return value.to_s
          Severity: Major
          Found in openc3/lib/openc3/packets/json_packet.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                      return value
            Severity: Major
            Found in openc3/lib/openc3/packets/json_packet.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return nil
              Severity: Major
              Found in openc3/lib/openc3/packets/json_packet.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return value
                Severity: Major
                Found in openc3/lib/openc3/packets/json_packet.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                        return nil
                  Severity: Major
                  Found in openc3/lib/openc3/packets/json_packet.rb - About 30 mins to fix

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

                            case reduced_type
                            when :AVG
                              value = @json_hash["#{name}__A"]
                            when :STDDEV
                              value = @json_hash["#{name}__S"]
                    Severity: Minor
                    Found in openc3/lib/openc3/packets/json_packet.rb and 1 other location - About 50 mins to fix
                    openc3/lib/openc3/packets/json_packet.rb on lines 82..90

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

                    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

                              case reduced_type
                              when :AVG
                                value = @json_hash["#{name}__CA"]
                              when :STDDEV
                                value = @json_hash["#{name}__CS"]
                    Severity: Minor
                    Found in openc3/lib/openc3/packets/json_packet.rb and 1 other location - About 50 mins to fix
                    openc3/lib/openc3/packets/json_packet.rb on lines 97..105

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

                    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

                        def read_all(value_type = :CONVERTED, reduced_type = nil, names = nil)
                          result = {}
                          names = read_all_names() unless names
                          names.each do |name|
                            result[name] = read(name, value_type, reduced_type)
                    Severity: Minor
                    Found in openc3/lib/openc3/packets/json_packet.rb and 1 other location - About 20 mins to fix
                    openc3/lib/openc3/packets/json_packet.rb on lines 181..187

                    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

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

                        def read_all_with_limits_states(value_type = :CONVERTED, reduced_type = nil, names = nil)
                          result = {}
                          names = read_all_names() unless names
                          names.each do |name|
                            result[name] = read_with_limits_state(name, value_type, reduced_type)
                    Severity: Minor
                    Found in openc3/lib/openc3/packets/json_packet.rb and 1 other location - About 20 mins to fix
                    openc3/lib/openc3/packets/json_packet.rb on lines 168..174

                    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