diaspora/diaspora_federation

View on GitHub

Showing 16 of 34 total issues

Class Entity has 32 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Entity
    extend PropertiesDSL
    include Logging

    # Invalid XML characters
Severity: Minor
Found in lib/diaspora_federation/entity.rb - About 4 hrs to fix

    Method json_data has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def json_data
          enriched_properties.map {|key, value|
            type = self.class.class_props[key]
            next if optional_nil_value?(key, value)
    
    
    Severity: Minor
    Found in lib/diaspora_federation/entity.rb - About 2 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 validate_config has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_config
          configuration_error "server_uri: Missing or invalid" unless @server_uri.respond_to? :host
    
          unless defined?(::Rails) && !::Rails.env.production?
            configuration_error "certificate_authorities: Not configured" if @certificate_authorities.nil?
    Severity: Minor
    Found in lib/diaspora_federation.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_xml_name has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def determine_xml_name(name, type, opts={})
          if !type.instance_of?(Symbol) && opts.has_key?(:xml_name)
            raise ArgumentError, "xml_name is not supported for nested entities"
          end
    
    
    Severity: Minor
    Found in lib/diaspora_federation/properties_dsl.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 get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def get(url, http_fallback=false)
            logger.info "Fetching #{url} for #{diaspora_id}"
            response = HttpClient.get(url)
            raise "Failed to fetch #{url}: #{response.status}" unless response.success?
            response.body
    Severity: Minor
    Found in lib/diaspora_federation/discovery/discovery.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 parse_string has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse_string(type, text)
            case type
            when :timestamp
              begin
                Time.parse(text).utc
    Severity: Minor
    Found in lib/diaspora_federation/parsers/base_parser.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 valid_value? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def valid_value?(value)
            return false if value.nil?
    
            if value.is_a?(String)
              true if value =~ /\A(true|false|t|f|yes|no|y|n|1|0)\z/i
    Severity: Minor
    Found in lib/diaspora_federation/validators/rules/boolean.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 parse_element_from_value has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse_element_from_value(type, value)
            return if value.nil?
            if %i[integer boolean timestamp].include?(type) && !value.is_a?(String)
              value
            elsif type.instance_of?(Symbol)
    Severity: Minor
    Found in lib/diaspora_federation/parsers/json_parser.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 to_json has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def to_json
            {
              subject:    subject,
              expires:    (expires.strftime(DATETIME_FORMAT) if expires.instance_of?(DateTime)),
              aliases:    (aliases if aliases.any?),
    Severity: Minor
    Found in lib/diaspora_federation/discovery/xrd_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 validate_response_and_update_pod has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def validate_response_and_update_pod(request, response)
              url = URI.parse(request.url)
              effective_url = URI.parse(response.effective_url)
              same_host = url.host == effective_url.host
    
    
    Severity: Minor
    Found in lib/diaspora_federation/federation/sender/hydra_wrapper.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 to_xml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def to_xml
            Nokogiri::XML::Builder.new(encoding: "UTF-8") {|xml|
              xml.XRD("xmlns" => XMLNS) {
                xml.Expires(expires.strftime(DATETIME_FORMAT)) if expires.instance_of?(DateTime)
    
    
    Severity: Minor
    Found in lib/diaspora_federation/discovery/xrd_document.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 receive_private has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.receive_private(data, recipient_private_key, recipient_id, legacy=false)
            raise ArgumentError, "no recipient key provided" unless recipient_private_key.instance_of?(OpenSSL::PKey::RSA)
            magic_env = if legacy
                          Salmon::EncryptedSlap.from_xml(data, recipient_private_key)
                        else
    Severity: Minor
    Found in lib/diaspora_federation/federation/receiver.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 validate_http_config has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_http_config
          configuration_error "http_concurrency: please configure a number" unless @http_concurrency.is_a?(Integer)
          configuration_error "http_timeout: please configure a number" unless @http_timeout.is_a?(Integer)
    
          return unless !@http_verbose.is_a?(TrueClass) && !@http_verbose.is_a?(FalseClass)
    Severity: Minor
    Found in lib/diaspora_federation.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 instantiate_nested has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def instantiate_nested(name, value)
          if value.instance_of?(Array)
            return value unless value.first.instance_of?(Hash)
            value.map {|hash| self.class.class_props[name].first.new(hash) }
          elsif value.instance_of?(Hash)
    Severity: Minor
    Found in lib/diaspora_federation/entity.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

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

          def self.xml_data(xrd_doc)
            doc = parse_xrd_document(xrd_doc)
    
            {}.tap do |data|
              exp_elem = doc.at_xpath("xrd:XRD/xrd:Expires", NS)
    Severity: Minor
    Found in lib/diaspora_federation/discovery/xrd_document.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

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

        def resolv_aliases(data)
          data.map {|name, value|
            if class_prop_aliases.has_key? name
              prop_name = class_prop_aliases[name]
              raise InvalidData, "only use '#{name}' OR '#{prop_name}'" if data.has_key? prop_name
    Severity: Minor
    Found in lib/diaspora_federation/properties_dsl.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

    Severity
    Category
    Status
    Source
    Language