QutBioacoustics/baw-workers

View on GitHub
lib/baw-workers/storage/common.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method validate_job_id has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def validate_job_id(opts)
        provided = validate_msg_provided(opts)
        fail ArgumentError, "#{validate_msg_base} job_id. #{provided}" unless opts.include? :job_id
        fail ArgumentError, "job_id must not be blank. #{provided}" if opts[:job_id].blank?

Severity: Minor
Found in lib/baw-workers/storage/common.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 existing_files has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

      def existing_files
        existing_dirs.each do |dir|
          Find.find(dir) do |path|
            if FileTest.directory?(path)
              if File.basename(path)[0] == ?.
Severity: Minor
Found in lib/baw-workers/storage/common.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 validate_channel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def validate_channel(opts)
        provided = validate_msg_provided(opts)
        fail ArgumentError, "#{validate_msg_base} channel. #{provided}" unless opts.include? :channel
        fail ArgumentError, "channel #{validate_msg_eq_or_gt} 0: #{opts[:channel]}. #{provided}" unless opts[:channel].to_i >= 0
        fail ArgumentError, "channel must be an integer: #{opts[:channel]}. #{provided}" unless opts[:channel].to_i.to_s == opts[:channel].to_s
Severity: Minor
Found in lib/baw-workers/storage/common.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

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

      def validate_window(opts)
        provided = validate_msg_provided(opts)
        fail ArgumentError, "#{validate_msg_base} window. #{provided}" unless opts.include? :window

        unless BawAudioTools::AudioSox.window_options.include?(opts[:window].to_i)
Severity: Minor
Found in lib/baw-workers/storage/common.rb and 1 other location - About 45 mins to fix
lib/baw-workers/storage/common.rb on lines 187..192

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

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 validate_window_function(opts)
        provided = validate_msg_provided(opts)
        fail ArgumentError, "#{validate_msg_base} window function. #{provided}" unless opts.include? :window_function

        unless BawAudioTools::AudioSox.window_function_options.include?(opts[:window_function].to_s)
Severity: Minor
Found in lib/baw-workers/storage/common.rb and 1 other location - About 45 mins to fix
lib/baw-workers/storage/common.rb on lines 169..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 41.

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

      def validate_file_name(opts)
        provided = validate_msg_provided(opts)
        fail ArgumentError, "#{validate_msg_base} file_name. #{provided}" unless opts.include? :file_name
        fail ArgumentError, "file_name must not be nil. #{provided}" if opts[:file_name].nil?
Severity: Minor
Found in lib/baw-workers/storage/common.rb and 2 other locations - About 20 mins to fix
lib/baw-workers/storage/common.rb on lines 120..123
lib/baw-workers/storage/common.rb on lines 161..164

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

      def validate_original_format(opts)
        provided = validate_msg_provided(opts)
        fail ArgumentError, "#{validate_msg_base} original_format. #{provided}" unless opts.include? :original_format
        fail ArgumentError, "original_format must not be blank. #{provided}" if opts[:original_format].blank?
Severity: Minor
Found in lib/baw-workers/storage/common.rb and 2 other locations - About 20 mins to fix
lib/baw-workers/storage/common.rb on lines 161..164
lib/baw-workers/storage/common.rb on lines 211..214

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

      def validate_format(opts)
        provided = validate_msg_provided(opts)
        fail ArgumentError, "#{validate_msg_base} format. #{provided}" unless opts.include? :format
        fail ArgumentError, "format must not be blank. #{provided}" if opts[:format].blank?
Severity: Minor
Found in lib/baw-workers/storage/common.rb and 2 other locations - About 20 mins to fix
lib/baw-workers/storage/common.rb on lines 120..123
lib/baw-workers/storage/common.rb on lines 211..214

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