zealot128/podfilter.de

View on GitHub
lib/file_mime_type_validator.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Method validate_each has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_each(record, attribute, value)
    raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base
    value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)
    return if value.length == 0

Severity: Minor
Found in lib/file_mime_type_validator.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_validity! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def check_validity!
    keys = CHECKS & options.keys

    if keys.empty?
      raise ArgumentError, 'Patterns unspecified. Specify the :content_type option.'
Severity: Minor
Found in lib/file_mime_type_validator.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 do_validation has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def do_validation(value, pattern, key, record, attribute)
Severity: Minor
Found in lib/file_mime_type_validator.rb - About 35 mins to fix

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

      def do_validation(value, pattern, key, record, attribute)
        return if value.file.content_type.send((pattern.is_a?(String) ? "==" : "=~" ), pattern)
    
        errors_options = options.except(*RESERVED_OPTIONS)
    
    
    Severity: Minor
    Found in lib/file_mime_type_validator.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