app/messages/metadata_validator_helper.rb
Method key_error
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
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?
- Read upRead up
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
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)
- Read upRead up
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
Open
return MetadataError.error('key cannot be empty string') unless valid_key_presence?(name)
Avoid too many return
statements within this method. Open
Open
return MetadataError.error("prefix 'cloudfoundry.org' is reserved") unless is_not_reserved
Avoid too many return
statements within this method. Open
Open
return MetadataError.error("'#{name[0...8]}...' is greater than #{MetadataValidatorHelper::MAX_METADATA_KEY_SIZE} characters") unless valid_size?(name)
Avoid too many return
statements within this method. Open
Open
return MetadataError.error("'#{name}' contains invalid characters") unless valid_characters?(name)
Avoid too many return
statements within this method. Open
Open
return MetadataError.error("'#{name}' starts or ends with invalid characters") unless start_end_alphanumeric?(name)