hackedteam/rcs-db

View on GitHub
scripts/xml_to_json.rb

Summary

Maintainability
F
1 wk
Test Coverage

Method parse_agents has a Cognitive Complexity of 173 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_agents(items)
      modules = []

      return modules if items.nil?

Severity: Minor
Found in scripts/xml_to_json.rb - About 3 days 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_events has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_events(items)
      events = []

      return events if items.nil?

Severity: Minor
Found in scripts/xml_to_json.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_actions has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_actions(items)
      actions = []

      return actions if items.nil?

Severity: Minor
Found in scripts/xml_to_json.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

File xml_to_json.rb has 393 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'json'
require 'optparse'
require 'pp'
require 'xmlsimple'

Severity: Minor
Found in scripts/xml_to_json.rb - About 5 hrs to fix

    Method parse_agents has 106 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def parse_agents(items)
          modules = []
    
          return modules if items.nil?
    
    
    Severity: Major
    Found in scripts/xml_to_json.rb - About 4 hrs to fix

      Method parse_events has 95 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def parse_events(items)
            events = []
      
            return events if items.nil?
      
      
      Severity: Major
      Found in scripts/xml_to_json.rb - About 3 hrs to fix

        Method parse_actions has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def parse_actions(items)
              actions = []
        
              return actions if items.nil?
        
        
        Severity: Minor
        Found in scripts/xml_to_json.rb - About 1 hr to fix

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

              def actions_with_start_stop(modules, actions, events)
                actions.each do |a|
                  # skip actions created during migration
                  next if a[:_mig]
                  # search for start action for camera, screenshot and position
          Severity: Minor
          Found in scripts/xml_to_json.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 agents_with_repetition has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def agents_with_repetition(modules, actions, events)
                modules.each do |m|
                  if m.has_key?('interval')
                    action = {:desc => "#{m[:module]} iteration", :_mig => true, :subactions => [{:action => 'module', :status => 'start', :module => m[:module]}] }
                    actions << action
          Severity: Minor
          Found in scripts/xml_to_json.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 xml_to_json has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def xml_to_json(content)
          
                modules = []
                actions = []
                events = []
          Severity: Minor
          Found in scripts/xml_to_json.rb - About 1 hr to fix

            Method parse_globals has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse_globals(items)
                  globals = {}
                  items.each_pair do |key, value|
                    if key == 'quota'
                      globals[:quota] = {:min => value.first['mindisk'].to_i*1024*1024, :max => value.first['maxlog'].to_i*1024*1024}
            Severity: Minor
            Found in scripts/xml_to_json.rb - About 45 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

                        unless a['sms'].nil?
                          a['sms'] = a['sms'].first
                          a['sms']['enabled'] = a['sms']['enabled'] == 'true' ? true : false
                          a['sms']['filter'] = a['sms']['filter'].first
                          a['sms']['filter']['history'] = a['sms']['filter']['history'] == 'true' ? true : false
            Severity: Major
            Found in scripts/xml_to_json.rb and 1 other location - About 1 hr to fix
            scripts/xml_to_json.rb on lines 289..294

            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

                        unless a['mms'].nil?
                          a['mms'] = a['mms'].first
                          a['mms']['enabled'] = a['mms']['enabled'] == 'true' ? true : false
                          a['mms']['filter'] = a['mms']['filter'].first
                          a['mms']['filter']['history'] = a['mms']['filter']['history'] == 'true' ? true : false
            Severity: Major
            Found in scripts/xml_to_json.rb and 1 other location - About 1 hr to fix
            scripts/xml_to_json.rb on lines 283..288

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

                          unless params['country'].nil?
                            e[:country] = params['country'].to_i
                            e[:country] = -1 if params['country'] == '*' or params['country'] == ''
                          end
            Severity: Minor
            Found in scripts/xml_to_json.rb and 3 other locations - About 25 mins to fix
            scripts/xml_to_json.rb on lines 82..85
            scripts/xml_to_json.rb on lines 90..93
            scripts/xml_to_json.rb on lines 94..97

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

                          unless params['network'].nil?
                            e[:network] = params['network'].to_i
                            e[:network] = -1 if params['network'] == '*' or params['network'] == ''
                          end
            Severity: Minor
            Found in scripts/xml_to_json.rb and 3 other locations - About 25 mins to fix
            scripts/xml_to_json.rb on lines 82..85
            scripts/xml_to_json.rb on lines 86..89
            scripts/xml_to_json.rb on lines 94..97

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

                          unless params['id'].nil?
                            e[:id] = params['id'].to_i
                            e[:id] = -1 if params['id'] == '*' or params['id'] == ''
                          end
            Severity: Minor
            Found in scripts/xml_to_json.rb and 3 other locations - About 25 mins to fix
            scripts/xml_to_json.rb on lines 86..89
            scripts/xml_to_json.rb on lines 90..93
            scripts/xml_to_json.rb on lines 94..97

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

                          unless params['area'].nil?
                            e[:area] = params['area'].to_i
                            e[:area] = -1 if params['area'] == '*' or params['area'] == ''
                          end
            Severity: Minor
            Found in scripts/xml_to_json.rb and 3 other locations - About 25 mins to fix
            scripts/xml_to_json.rb on lines 82..85
            scripts/xml_to_json.rb on lines 86..89
            scripts/xml_to_json.rb on lines 90..93

            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

                        a[:hook] = {:enabled => t['hook'].first['enabled'] == 'false' ? false : true,
                                    :processes => t['hook'].first['process']} unless t['hook'].nil?
            Severity: Minor
            Found in scripts/xml_to_json.rb and 1 other location - About 20 mins to fix
            scripts/xml_to_json.rb on lines 255..256

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

            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

                        a[:network] = {:enabled => t['network'].first['enabled'] == 'false' ? false : true,
                                       :processes => t['network'].first['process']} unless t['network'].nil?
            Severity: Minor
            Found in scripts/xml_to_json.rb and 1 other location - About 20 mins to fix
            scripts/xml_to_json.rb on lines 257..258

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

            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