SysMO-DB/seek

View on GitHub
app/models/content_blob.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Class ContentBlob has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class ContentBlob < ActiveRecord::Base

  include Seek::ContentTypeDetection
  include Seek::PdfExtraction
  include Seek::MimeTypes
Severity: Minor
Found in app/models/content_blob.rb - About 2 hrs to fix

    Method dump_tmp_io_object_to_file has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def dump_tmp_io_object_to_file
        raise Exception.new("You cannot define both :data content and a :tmp_io_object") unless @data.nil? || @tmp_io_object.nil?
        t1 = Time.now
        unless @tmp_io_object.nil?
          begin
    Severity: Minor
    Found in app/models/content_blob.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_url_content_type has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def check_url_content_type
        unless url.nil?
          begin
            response = RestClient.head url
            type = response.headers[:content_type] || ""
    Severity: Minor
    Found in app/models/content_blob.rb - About 55 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 data_io_object has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def data_io_object
        return @tmp_io_object unless @tmp_io_object.nil?
        return StringIO.new(@data) unless @data.nil? 
        return File.open(filepath,"rb") if file_exists?
        return StringIO.new(data_old) unless data_old.nil?
    Severity: Minor
    Found in app/models/content_blob.rb - About 35 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

    Avoid too many return statements within this method.
    Open

        return nil
    Severity: Major
    Found in app/models/content_blob.rb - About 30 mins to fix

      There are no issues that match your filters.

      Category
      Status