zacstewart/tengai

View on GitHub
ext/horizons/vector_ephemeris_parser.rb

Summary

Maintainability
F
1 mo
Test Coverage

File vector_ephemeris_parser.rb has 4347 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'date'
module Tengai
  class VectorEphemerisParser
    def self.parse(data, ephemeris_table_parser=EphemerisTableParser)
      data = data.unpack('c*') if data.is_a? String
Severity: Major
Found in ext/horizons/vector_ephemeris_parser.rb - About 1 wk to fix

    Method parse has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.parse(data, ephemeris_table_parser=EphemerisTableParser)
          data = data.unpack('c*') if data.is_a? String
          eof = data.length
    
          
    Severity: Minor
    Found in ext/horizons/vector_ephemeris_parser.rb - About 1 day 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 has 147 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.parse(data, ephemeris_table_parser=EphemerisTableParser)
          data = data.unpack('c*') if data.is_a? String
          eof = data.length
    
          
    Severity: Major
    Found in ext/horizons/vector_ephemeris_parser.rb - About 5 hrs to fix

      Avoid deeply nested control flow statements.
      Open

                  case _ephemeris_parser_actions[_acts - 1]
      when 0 then
      # line 6 "ext/horizons/vector_ephemeris_parser.rl"
              begin
       mark = p         end
      Severity: Major
      Found in ext/horizons/vector_ephemeris_parser.rb - About 45 mins to fix

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

        self._ephemeris_parser_trans_actions = [
            0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 1, 17, 
            0, 0, 0, 0, 0, 0, 0, 0, 
        Severity: Major
        Found in ext/horizons/vector_ephemeris_parser.rb and 1 other location - About 6 days to fix
        ext/horizons/vector_ephemeris_parser.rb on lines 3971..4171

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

        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

        self._ephemeris_parser_trans_targs = [
            1, 2, 3, 4, 5, 6, 7, 8, 
            9, 10, 11, 12, 13, 14, 15, 16, 
            17, 18, 19, 20, 948, 21, 22, 947, 
            22, 23, 24, 45, 25, 26, 27, 28, 
        Severity: Major
        Found in ext/horizons/vector_ephemeris_parser.rb and 1 other location - About 6 days to fix
        ext/horizons/vector_ephemeris_parser.rb on lines 4177..4377

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

        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 4 locations. Consider refactoring.
        Open

        self._ephemeris_parser_index_offsets = [
            0, 0, 2, 5, 8, 11, 14, 17, 
            20, 23, 26, 29, 32, 35, 38, 41, 
            44, 47, 50, 54, 61, 69, 73, 79, 
            82, 86, 90, 94, 98, 102, 106, 110, 
        Severity: Major
        Found in ext/horizons/vector_ephemeris_parser.rb and 3 other locations - About 6 days to fix
        ext/horizons/vector_ephemeris_parser.rb on lines 208..400
        ext/horizons/vector_ephemeris_parser.rb on lines 1920..2112
        ext/horizons/vector_ephemeris_parser.rb on lines 2118..2310

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

        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 4 locations. Consider refactoring.
        Open

        self._ephemeris_parser_single_lengths = [
            0, 1, 2, 2, 2, 2, 2, 2, 
            2, 2, 2, 2, 2, 2, 2, 2, 
            2, 2, 2, 2, 3, 2, 4, 2, 
            3, 3, 3, 3, 3, 3, 3, 3, 
        Severity: Major
        Found in ext/horizons/vector_ephemeris_parser.rb and 3 other locations - About 6 days to fix
        ext/horizons/vector_ephemeris_parser.rb on lines 208..400
        ext/horizons/vector_ephemeris_parser.rb on lines 2118..2310
        ext/horizons/vector_ephemeris_parser.rb on lines 2316..2508

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

        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 4 locations. Consider refactoring.
        Open

        self._ephemeris_parser_key_offsets = [
            0, 0, 1, 3, 5, 7, 9, 11, 
            13, 15, 17, 19, 21, 23, 25, 27, 
            29, 31, 33, 37, 47, 58, 62, 68, 
            70, 73, 76, 79, 82, 85, 88, 91, 
        Severity: Major
        Found in ext/horizons/vector_ephemeris_parser.rb and 3 other locations - About 6 days to fix
        ext/horizons/vector_ephemeris_parser.rb on lines 1920..2112
        ext/horizons/vector_ephemeris_parser.rb on lines 2118..2310
        ext/horizons/vector_ephemeris_parser.rb on lines 2316..2508

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

        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 4 locations. Consider refactoring.
        Open

        self._ephemeris_parser_range_lengths = [
            0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 
            0, 0, 1, 4, 4, 1, 1, 0, 
            0, 0, 0, 0, 0, 0, 0, 0, 
        Severity: Major
        Found in ext/horizons/vector_ephemeris_parser.rb and 3 other locations - About 6 days to fix
        ext/horizons/vector_ephemeris_parser.rb on lines 208..400
        ext/horizons/vector_ephemeris_parser.rb on lines 1920..2112
        ext/horizons/vector_ephemeris_parser.rb on lines 2316..2508

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

        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

            begin
              if _klen > 0
                 _lower = _keys
                 _upper = _keys + _klen - 1
        
        
        Severity: Major
        Found in ext/horizons/vector_ephemeris_parser.rb and 1 other location - About 4 hrs to fix
        ext/horizons/body_data_sheet_parser.rb on lines 53..96

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

        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

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

            if _goto_level <= _again
            if cs == 0
                _goto_level = _out
                next
            end
        Severity: Minor
        Found in ext/horizons/vector_ephemeris_parser.rb and 1 other location - About 15 mins to fix
        ext/horizons/body_data_sheet_parser.rb on lines 137..146

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

        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