the-oneacct-export-project/oneacct-export

View on GitHub
lib/oneacct_opts.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method parse has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.parse(args)
    options = OpenStruct.new

    opt_parser = OptionParser.new do |opts|
      opts.banner = 'Usage oneacct-export [options]'
Severity: Major
Found in lib/oneacct_opts.rb - About 2 hrs to fix

    Method check_output_type_specific_settings has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.check_output_type_specific_settings
        if APEL_OT.include?(Settings.output['output_type'])
          unless Settings.output['apel'] && Settings.output.apel['site_name'] &&
              Settings.output.apel['cloud_type'] && Settings.output.apel['endpoint']
            fail ArgumentError, 'Missing some mandatory parameters for APEL output type. Check your configuration file.'
    Severity: Minor
    Found in lib/oneacct_opts.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 check_options_restrictions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.check_options_restrictions(options)
        # make sure only one time option is used
        if (options.records_from || options.records_to) && options.records_for
          fail ArgumentError, 'Cannot use both time period and time range options.'
        end
    Severity: Minor
    Found in lib/oneacct_opts.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 parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.parse(args)
        options = OpenStruct.new
    
        opt_parser = OptionParser.new do |opts|
          opts.banner = 'Usage oneacct-export [options]'
    Severity: Minor
    Found in lib/oneacct_opts.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

    Method set_defaults has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.set_defaults(options)
        options.blocking = BLOCKING_DEFAULT unless options.blocking
        options.timeout = TIMEOUT_DEFAULT if options.blocking unless options.timeout
        options.compatibility = COMPATIBILITY_DEFAULT unless options.compatibility
      end
    Severity: Minor
    Found in lib/oneacct_opts.rb - About 25 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 check_settings_restrictions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.check_settings_restrictions
        # make sure all mandatory parameters are set
        unless Settings['output'] && Settings.output['output_dir'] && Settings.output['output_type']
          fail ArgumentError, 'Missing some mandatory parameters. Check your configuration file.'
        end
    Severity: Minor
    Found in lib/oneacct_opts.rb - About 25 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

    There are no issues that match your filters.

    Category
    Status