OpenC3/cosmos

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

Summary

Maintainability
D
1 day
Test Coverage

Method to_config has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def to_config(cmd_or_tlm, default_endianness)
      config = ''
      if cmd_or_tlm == :TELEMETRY
        if self.array_size
          config << "  ARRAY_ITEM #{self.name.to_s.quote_if_necessary} #{self.bit_offset} #{self.bit_size} #{self.data_type} #{self.array_size} \"#{self.description.to_s.gsub("\"", "'")}\""
Severity: Major
Found in openc3/lib/openc3/packets/packet_item.rb - About 2 hrs to fix

    Method as_json has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def as_json(*a)
          config = {}
          config['name'] = self.name
          config['bit_offset'] = self.bit_offset
          config['bit_size'] = self.bit_size
    Severity: Major
    Found in openc3/lib/openc3/packets/packet_item.rb - About 2 hrs to fix

      Method from_json has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.from_json(hash)
            # Convert strings to symbols
            endianness = hash['endianness'] ? hash['endianness'].intern : nil
            data_type = hash['data_type'] ? hash['data_type'].intern : nil
            overflow = hash['overflow'] ? hash['overflow'].intern : nil
      Severity: Major
      Found in openc3/lib/openc3/packets/packet_item.rb - About 2 hrs to fix

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

            def to_hash
              hash = super()
              hash['format_string'] = self.format_string
              if self.read_conversion
                hash['read_conversion'] = self.read_conversion.to_s
        Severity: Minor
        Found in openc3/lib/openc3/packets/packet_item.rb - About 1 hr to fix

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

              def initialize(name, bit_offset, bit_size, data_type, endianness, array_size = nil, overflow = :ERROR)
          Severity: Major
          Found in openc3/lib/openc3/packets/packet_item.rb - About 50 mins to fix

            Avoid deeply nested control flow statements.
            Open

                          raise ArgumentError, "#{@name}: maximum must be a Float but is a #{@range.last.class}" unless Float === @range.last or Integer === @range.last
            Severity: Major
            Found in openc3/lib/openc3/packets/packet_item.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                            raise ArgumentError, "#{@name}: maximum must be a Integer but is a #{@range.last.class}" unless Integer === @range.last
              Severity: Major
              Found in openc3/lib/openc3/packets/packet_item.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                              raise ArgumentError, "#{@name}: minimum must be a Integer but is a #{@range.first.class}" unless Integer === @range.first
                Severity: Major
                Found in openc3/lib/openc3/packets/packet_item.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                raise ArgumentError, "#{@name}: minimum must be a Float but is a #{@range.first.class}" unless Float === @range.first or Integer === @range.first
                  Severity: Major
                  Found in openc3/lib/openc3/packets/packet_item.rb - About 45 mins to fix

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

                          if hash['read_conversion']
                            begin
                              item.read_conversion = OpenC3::const_get(hash['read_conversion']['class']).new(*hash['read_conversion']['params'])
                            rescue => error
                              Logger.instance.error "#{item.name} read_conversion of #{hash['read_conversion']} could not be instantiated due to #{error}"
                    Severity: Minor
                    Found in openc3/lib/openc3/packets/packet_item.rb and 1 other location - About 45 mins to fix
                    openc3/lib/openc3/packets/packet_item.rb on lines 559..564

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

                    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

                          if hash['write_conversion']
                            begin
                              item.write_conversion = OpenC3::const_get(hash['write_conversion']['class']).new(*hash['write_conversion']['params'])
                            rescue => error
                              Logger.instance.error "#{item.name} write_conversion of #{hash['write_conversion']} could not be instantiated due to #{error}"
                    Severity: Minor
                    Found in openc3/lib/openc3/packets/packet_item.rb and 1 other location - About 45 mins to fix
                    openc3/lib/openc3/packets/packet_item.rb on lines 552..557

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

                    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

                              config << "  ARRAY_ITEM #{self.name.to_s.quote_if_necessary} #{self.bit_offset} #{self.bit_size} #{self.data_type} #{self.array_size} \"#{self.description.to_s.gsub("\"", "'")}\""
                    Severity: Minor
                    Found in openc3/lib/openc3/packets/packet_item.rb and 1 other location - About 30 mins to fix
                    openc3/lib/openc3/packets/packet_item.rb on lines 396..396

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

                    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

                              config << "  ARRAY_PARAMETER #{self.name.to_s.quote_if_necessary} #{self.bit_offset} #{self.bit_size} #{self.data_type} #{self.array_size} \"#{self.description.to_s.gsub("\"", "'")}\""
                    Severity: Minor
                    Found in openc3/lib/openc3/packets/packet_item.rb and 1 other location - About 30 mins to fix
                    openc3/lib/openc3/packets/packet_item.rb on lines 380..380

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

                    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_conversion=(read_conversion)
                          if read_conversion
                            raise ArgumentError, "#{@name}: read_conversion must be a OpenC3::Conversion but is a #{read_conversion.class}" unless OpenC3::Conversion === read_conversion or OpenC3::PythonProxy === read_conversion
                    
                            @read_conversion = read_conversion.clone
                    Severity: Minor
                    Found in openc3/lib/openc3/packets/packet_item.rb and 1 other location - About 25 mins to fix
                    openc3/lib/openc3/packets/packet_item.rb on lines 141..147

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

                    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 write_conversion=(write_conversion)
                          if write_conversion
                            raise ArgumentError, "#{@name}: write_conversion must be a OpenC3::Conversion but is a #{write_conversion.class}" unless OpenC3::Conversion === write_conversion or OpenC3::PythonProxy === write_conversion
                    
                            @write_conversion = write_conversion.clone
                    Severity: Minor
                    Found in openc3/lib/openc3/packets/packet_item.rb and 1 other location - About 25 mins to fix
                    openc3/lib/openc3/packets/packet_item.rb on lines 131..137

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

                    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