duke-libraries/ddr-models

View on GitHub

Showing 35 of 35 total issues

Method generate_derivative! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def generate_derivative!(derivative)
      tempdir_path = File.join(Dir.tmpdir, Dir::Tmpname.make_tmpname('',nil))
      begin
        tempdir = FileUtils.mkdir(tempdir_path).first
        generator_source_path = source_datastream.external? ? source_datastream.file_path
Severity: Minor
Found in lib/ddr/managers/derivatives_manager.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 desc_metadata_terms has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def desc_metadata_terms *args
      return Ddr::Datastreams::DescriptiveMetadataDatastream.term_names if args.empty?
      arg = args.pop
      terms = case arg.to_sym
              when :empty
Severity: Minor
Found in lib/ddr/models/describable.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 call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def self.call(*args)
      event = ActiveSupport::Notifications::Event.new(*args)
      repo_id, identifier_id, reason = event.payload.values_at(:pid, :permanent_id, :reason)
      case event.name
      when Base::UPDATE
Severity: Minor
Found in lib/ddr/models/permanent_id.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 add_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def add_file(file, dsid, mime_type: nil, external: false, original_filename: nil)
      mime_type         ||= MediaType.call(file) # XXX Should we use original_filename, if present?
      source_path         = Ddr::Utils.file_path(file)
      original_filename ||= Ddr::Utils.file_name(file)
      file_to_add = FileToAdd.new(dsid, source_path, original_filename)
Severity: Minor
Found in lib/ddr/models/file_management.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 dereferenced_hash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def dereferenced_hash
      contents = []
      contents.concat(divs.map { |div| div.dereferenced_hash }) unless divs.empty?
      contents.concat(fptrs.map { |fptr| fptr.dereferenced_hash }) unless fptrs.empty?
      contents.concat(mptrs.map { |mptr| mptr.dereferenced_hash }) unless mptrs.empty?
Severity: Minor
Found in lib/ddr/models/structures/div.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 user_groups has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def user_groups(user, raw = false)
        groups = []
        subject_id = user.principal_name.scan(SUBJECT_ID_RE).first
        return groups unless subject_id
        begin
Severity: Minor
Found in lib/ddr/auth/grouper_gateway.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 method_missing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def method_missing(name, *args, &block)
      if args.empty? && !block
        begin
          field = Ddr::Index::Fields.get(name)
        rescue NameError
Severity: Minor
Found in lib/ddr/models/solr_document.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 add_use_to_structure has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def add_use_to_structure(structure, filegrp, div, use, datastream_name)
Severity: Minor
Found in app/models/component.rb - About 35 mins to fix

    Method build_default_structure has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def build_default_structure
        document = Ddr::Models::Structure.xml_template
        structure = Ddr::Models::Structure.new(document)
        metshdr = structure.add_metshdr
        structure.add_agent(parent: metshdr, role: Ddr::Models::Structures::Agent::ROLE_CREATOR,
    Severity: Minor
    Found in app/models/component.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

    Method relationship_object_reflection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.relationship_object_reflection(model, relationship_name)
        reflection = nil
        if model
          begin
            reflections = model.constantize.reflections
    Severity: Minor
    Found in lib/ddr/utils.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

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

        def self.build(args)
          node = Nokogiri::XML::Node.new('fptr', args[:document])
          node['ID'] = args[:id] if args[:id]
          node['FILEID'] = args[:fileid] if args[:fileid]
          node
    Severity: Minor
    Found in lib/ddr/models/structures/fptr.rb and 2 other locations - About 30 mins to fix
    lib/ddr/models/structures/file.rb on lines 40..44
    lib/ddr/models/structures/file_grp.rb on lines 27..31

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

    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 self.build(args)
          node = Nokogiri::XML::Node.new('file', args[:document])
          node['ID'] = args[:id] if args[:id]
          node['USE'] = args[:use] if args[:use]
          node
    Severity: Minor
    Found in lib/ddr/models/structures/file.rb and 2 other locations - About 30 mins to fix
    lib/ddr/models/structures/file_grp.rb on lines 27..31
    lib/ddr/models/structures/fptr.rb on lines 23..27

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

    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 self.build(args)
          node = Nokogiri::XML::Node.new('fileGrp', args[:document])
          node['ID'] = args[:id] if args[:id]
          node['USE'] = args[:use] if args[:use]
          node
    Severity: Minor
    Found in lib/ddr/models/structures/file_grp.rb and 2 other locations - About 30 mins to fix
    lib/ddr/models/structures/file.rb on lines 40..44
    lib/ddr/models/structures/fptr.rb on lines 23..27

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

    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

      module Events
        extend ActiveSupport::Autoload
    
        autoload :Event
        autoload :CreationEvent
    Severity: Minor
    Found in lib/ddr/events.rb and 1 other location - About 15 mins to fix
    lib/ddr/models.rb on lines 73..86

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

    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

        module Structures
          extend ActiveSupport::Autoload
          autoload :Agent
          autoload :Div
          autoload :File
    Severity: Minor
    Found in lib/ddr/models.rb and 1 other location - About 15 mins to fix
    lib/ddr/events.rb on lines 2..17

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

    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

    Severity
    Category
    Status
    Source
    Language