SysMO-DB/seek

View on GitHub
app/helpers/api_helper.rb

Summary

Maintainability
D
2 days
Test Coverage

Method extended_xml has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

  def extended_xml builder,object        
    
    submitter = determine_submitter object
    builder.tag! "submitter" do 
      api_partial(builder,submitter)
Severity: Minor
Found in app/helpers/api_helper.rb - About 6 hrs 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

File api_helper.rb has 302 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ApiHelper
  
  def xml_root_attributes
    { "xmlns" => "http://www.sysmo-db.org/2010/xml/rest",
      "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
Severity: Minor
Found in app/helpers/api_helper.rb - About 3 hrs to fix

    Method extended_xml has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def extended_xml builder,object        
        
        submitter = determine_submitter object
        builder.tag! "submitter" do 
          api_partial(builder,submitter)
    Severity: Major
    Found in app/helpers/api_helper.rb - About 2 hrs to fix

      Method xlink_title has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def xlink_title(item, item_type_name=nil)
          case item
            when String
            return item
          else
      Severity: Minor
      Found in app/helpers/api_helper.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 policy_xml has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def policy_xml builder,asset
          policy = asset.policy
          unless policy.nil?
            builder.tag! "policy" do
              dc_core_xml builder,policy
      Severity: Minor
      Found in app/helpers/api_helper.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 determine_submitter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def determine_submitter object
          #FIXME: needs to be the creators for assets
          return object.owner if object.respond_to?("owner")
          result = object.contributor if object.respond_to?("contributor") && !object.kind_of?(Permission)
          if (result)
      Severity: Minor
      Found in app/helpers/api_helper.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 core_xlink has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def core_xlink object,include_title=true
          if (object.class.name.include?("::Version"))
            xlink=xlink_attributes(uri_for_object(object.parent,{:params=>{:version=>object.version}}))
          else
            xlink=xlink_attributes(uri_for_object(object))  
      Severity: Minor
      Found in app/helpers/api_helper.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 assets_list_xml has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def assets_list_xml builder,assets,tag="assets",include_core=true,include_resource=true
      Severity: Minor
      Found in app/helpers/api_helper.rb - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status