cloudfoundry/cloud_controller_ng

View on GitHub
app/messages/metadata_validator_helper.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method key_error has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def key_error
      return MetadataError.error('key cannot be empty string') unless valid_key_presence?(key)
      return MetadataError.error("key has more than one '/'") unless valid_key_format?
      return MetadataError.error("prefix '#{prefix}' must be in valid dns format") unless valid_prefix_format?
      return MetadataError.error("prefix '#{prefix[0...8]}...' is greater than #{MAX_METADATA_PREFIX_SIZE} characters") unless valid_prefix_size?
Severity: Minor
Found in app/messages/metadata_validator_helper.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 value_error has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def value_error
      return MetadataError.none if value.nil? || value == ''

      return MetadataError.error("'#{value}' contains invalid characters") unless valid_characters?(value)
      return MetadataError.error("'#{value}' starts or ends with invalid characters") unless start_end_alphanumeric?(value)
Severity: Minor
Found in app/messages/metadata_validator_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

Avoid too many return statements within this method.
Open

      return MetadataError.error('key cannot be empty string') unless valid_key_presence?(name)
Severity: Major
Found in app/messages/metadata_validator_helper.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return MetadataError.error("'#{name[0...8]}...' is greater than #{MetadataValidatorHelper::MAX_METADATA_KEY_SIZE} characters") unless valid_size?(name)
    Severity: Major
    Found in app/messages/metadata_validator_helper.rb - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

            return MetadataError.error("'#{name}' starts or ends with invalid characters") unless start_end_alphanumeric?(name)
      Severity: Major
      Found in app/messages/metadata_validator_helper.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return MetadataError.error("prefix 'cloudfoundry.org' is reserved") unless is_not_reserved
        Severity: Major
        Found in app/messages/metadata_validator_helper.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                return MetadataError.error("'#{name}' contains invalid characters") unless valid_characters?(name)
          Severity: Major
          Found in app/messages/metadata_validator_helper.rb - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status