Showing 32 of 42 total issues
File cli.rb
has 342 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'thor'
require 'thor/runner'
module Locomotive
module Wagon
Method template
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
def template
%{
<DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
Method parse
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def parse(chars)
curlies, escaping = 0, false
chars.map do |char|
if escaping
escaping = false
- 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 decode_json_attribute
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def decode_json_attribute(attributes, name, &block)
value = attributes.delete(name)
return if value.blank?
- 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 parse
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse(chars)
curlies, escaping = 0, false
chars.map do |char|
if escaping
escaping = false
Method smoosh
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def smoosh(chars)
[].tap do |out|
until chars.empty?
char = chars.shift
if char == "*" and chars.first == "*"
- 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 write_page
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def write_page(page, locale = nil)
instrument :writing, label: "#{page.fullpath} (#{locale})"
filepath = data_path(page, locale)
Method fetch_content_entries
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def fetch_content_entries(content_type, &block)
page = 1
while page do
entries, _next_page = {}, nil
- 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 persist
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def persist(decorated_entity)
_attributes = decorated_entity.to_hash
# push the picture only if there is no existing remote picture
_attributes.delete(:picture) if remote_site['picture_url'].present?
- 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 connection_information
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def connection_information
if information = read_deploy_settings(self.env, self.path)
# the deployment env exists and contains all the information we need to move on
information
else
- 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 to_json
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def to_json
self._list.map do |template|
# puts template.klass.class_options.inspect
# puts class_options_to_json
path = template.klass.source_root ? File.expand_path(template.klass.source_root) : nil
- 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 check_path!
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def check_path!(path = nil)
path ||= options['path']
path = path == '.' ? Dir.pwd : File.expand_path(path)
- 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 prepare_value_for_hash
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def prepare_value_for_hash(value)
if value.is_a?(Array) && value.any? { |v| v.respond_to?(:__attributes__) }
value.map(&:to_hash)
elsif value.is_a?(Array) && value.empty?
nil # reset the array
- 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 extract_fields
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def extract_fields(fields)
fields.map do |raw_attributes|
name, type, label, required, localized, target_content_type_slug = raw_attributes.split(':')
OpenStruct.new(
- 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 replace_asset_urls
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def replace_asset_urls(content)
return '' if content.blank?
_content = content.dup
- 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 fetch_content_types
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def fetch_content_types(&block)
api_client.content_types.all.each do |content_type|
content_type.attributes['localized_names'] = content_type.fields.map { |f| f['localized'] ? f['name'] : nil }.compact
content_type.attributes['urls_names'] = content_type.fields.map { |f| %w(file string text).include?(f['type']) ? f['name'] : nil }.compact
yield(content_type)
- 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 select_options_yaml
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def select_options_yaml(options)
return if options.blank?
ordered_options = options.sort { |option| option['position'] }
- 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 scalar
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def scalar value, anchor, tag, plain, quoted, style
Method list_templates
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def list_templates
force_color_if_asked(options)
require 'locomotive/wagon/generators/site'
require File.expand_path(options[:lib]) if options[:lib]
if Locomotive::Wagon::Generators::Site.empty?
- 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 delete
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def self.delete(env, path, resource, slug, shell)