josephholsten/discodactyl

View on GitHub

Showing 11 of 11 total issues

Method get_uris_by_rel has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

      def get_uris_by_rel(uri, rel, params = {})
        begin
          uri = URI.parse(uri.to_s) unless uri.respond_to?('open')
          Discodactyl.log.debug "Getting uris for uri #{uri.inspect} by rel #{rel.inspect} with params #{params.inspect}" if Discodactyl.log
          resource = uri.open
Severity: Minor
Found in lib/discodactyl/resource_discovery.rb - About 5 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

Method hcard_from_uri has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  def self.hcard_from_uri(uri, io)
    begin
      Discodactyl.log.debug("hCard lookup for #{uri}") if Discodactyl.log
      if hcards = Prism.find(uri, :hcard)
        hcards.each do |hcard|
Severity: Minor
Found in lib/discodactyl/cli/format.rb - About 3 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

Method get_uris_by_rel has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def get_uris_by_rel(uri, rel, params = {})
        begin
          uri = URI.parse(uri.to_s) unless uri.respond_to?('open')
          Discodactyl.log.debug "Getting uris for uri #{uri.inspect} by rel #{rel.inspect} with params #{params.inspect}" if Discodactyl.log
          resource = uri.open
Severity: Minor
Found in lib/discodactyl/resource_discovery.rb - About 1 hr to fix

    Method parse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse(string)
            LinkHeader.new.tap do |params|
              if string =~ /^<([^>]+)>(.*)$/
                params[:href] = $1
                $2.split(/;\s*/).each do |part|
    Severity: Minor
    Found in lib/discodactyl/link_header.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

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

          begin
            raw = uri.open
          rescue OpenURI::HTTPError => error
            if error.io.status[1] == 'Not Found'
              error.io.base_uri = uri
    Severity: Minor
    Found in lib/discodactyl/host_meta_jrd.rb and 1 other location - About 55 mins to fix
    lib/discodactyl/host_meta.rb on lines 20..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 45.

    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

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

            begin
              raw = uri.open
            rescue OpenURI::HTTPError => error
              if error.io.status[1] == 'Not Found'
                error.io.base_uri = uri
    Severity: Minor
    Found in lib/discodactyl/host_meta.rb and 1 other location - About 55 mins to fix
    lib/discodactyl/host_meta_jrd.rb on lines 20..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 45.

    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

    Method for_rel has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.for_rel(rel)
        case rel
        when 'http://microformats.org/profile/hcard' then
          lambda {|uri, io| Discodactyl::CLI::Format.hcard_from_uri(uri, io) }
        when 'http://schemas.google.com/g/2010#updates-from' then
    Severity: Minor
    Found in lib/discodactyl/cli/format.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 == has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def ==(other)
          return false unless other.class == self.class
          return false unless other.instance_variables == self.instance_variables
          self.instance_variables.each do |var|
            self_var = self.instance_variable_get(var)
    Severity: Minor
    Found in lib/discodactyl/uri_template.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 activities_from_uri has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.activities_from_uri(uri, io)
        Discodactyl.log.debug("Activity feed lookup for #{uri}") if Discodactyl.log
        begin
          if uri && (feed = Feedzirra::Feed.fetch_and_parse(uri)) && feed.respond_to?(:entries)
            Array(feed.entries).each do |entry|
    Severity: Minor
    Found in lib/discodactyl/cli/format.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

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

                link.rel = element['rel']
                link.type = element['type']
                link.href = element['href']
                link.title = element['title']
                link.template = URITemplate.new(element['template']) unless link.href
    Severity: Minor
    Found in lib/discodactyl/jrd/link.rb and 1 other location - About 35 mins to fix
    lib/discodactyl/xrd/link.rb on lines 11..16

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

    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

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

              link.rel = element['rel']
              link.type = element['type']
              link.href = element['href']
              link.title = element['title']
              link.template = URITemplate.new(element['template']) unless link.href
    Severity: Minor
    Found in lib/discodactyl/xrd/link.rb and 1 other location - About 35 mins to fix
    lib/discodactyl/jrd/link.rb on lines 11..16

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

    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