Assignment Branch Condition size for create_file is too high. [18.03/15] Open
def self.create_file(file, scope, template)
file_source = IO.read(template.template_path.join(file[TEMPLATE_FILE_PATH_KEY]))
Liquid::Template.file_system = Liquid::LocalFileSystem.new(template.template_path.join('snippets'), '%s.liquid')
template = Liquid::Template.parse(file_source)
- Read upRead up
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [12/10] Open
def self.create_file(file, scope, template)
file_source = IO.read(template.template_path.join(file[TEMPLATE_FILE_PATH_KEY]))
Liquid::Template.file_system = Liquid::LocalFileSystem.new(template.template_path.join('snippets'), '%s.liquid')
template = Liquid::Template.parse(file_source)
- Read upRead up
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Use 2 (not 1) spaces for indentation. Open
template_default_text = '{{ prefix }}{{ module_info.name }}{{ module_info.file_basename }}'
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Tab detected. Open
def self.create_file(file, scope, template)
- Exclude checks
Redundant return
detected. To return multiple values, use an array. Open
return file_name, content
- Read upRead up
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Tab detected. Open
template_default_text = '{{ prefix }}{{ module_info.name }}{{ module_info.file_basename }}'
- Exclude checks
Tab detected. Open
end
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Line is too long. [94/80] Open
template_default_text = '{{ prefix }}{{ module_info.name }}{{ module_info.file_basename }}'
- Exclude checks
Tab detected. Open
- Exclude checks
Incorrect indentation detected (column 2 instead of 1). Open
# Responsible for generating code using provided liquid templates
- Read upRead up
- Exclude checks
This cops checks the indentation of comments.
Example:
# bad
# comment here
def method_name
end
# comment here
a = 'hello'
# yet another comment
if true
true
end
# good
# comment here
def method_name
end
# comment here
a = 'hello'
# yet another comment
if true
true
end
Use 2 (not 1) spaces for indentation. Open
class ContentGenerator
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Tab detected. Open
module_info['file_basename'] = file_basename
- Exclude checks
Incorrect indentation detected (column 4 instead of 2). Open
# @return [String], [String] The generated file_name and body
- Read upRead up
- Exclude checks
This cops checks the indentation of comments.
Example:
# bad
# comment here
def method_name
end
# comment here
a = 'hello'
# yet another comment
if true
true
end
# good
# comment here
def method_name
end
# comment here
a = 'hello'
# yet another comment
if true
true
end
Line is too long. [115/80] Open
Liquid::Template.file_system = Liquid::LocalFileSystem.new(template.template_path.join('snippets'), '%s.liquid')
- Exclude checks
Line is too long. [87/80] Open
# @param file [Hash<String,String>] A hashmap with template's filename and filepath
- Exclude checks
Redundant self
detected. Open
filename_template = self.file_name_template(file)
- Read upRead up
- Exclude checks
This cop checks for redundant uses of self
.
The usage of self
is only needed when:
Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.
Calling an attribute writer to prevent an local variable assignment.
Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.
Note we allow uses of self
with operators because it would be awkward
otherwise.
Example:
# bad
def foo(bar)
self.baz
end
# good
def foo(bar)
self.bar # Resolves name clash with the argument.
end
def foo
bar = 1
self.bar # Resolves name clash with the local variable.
end
def foo
%w[x y z].select do |bar|
self.bar == bar # Resolves name clash with argument of the block.
end
end
Tab detected. Open
end
- Exclude checks
Tab detected. Open
return Liquid::Template.parse(template_text)
- Exclude checks
Tab detected. Open
Liquid::Template.file_system = Liquid::LocalFileSystem.new(template.template_path.join('snippets'), '%s.liquid')
- Exclude checks
Tab detected. Open
file_name = filename_template.render(scope)
- Exclude checks
Tab detected. Open
return file_name, content
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Redundant return
detected. Open
return Liquid::Template.parse(template_text)
- Read upRead up
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Use 2 (not 1) spaces for indentation. Open
def self.create_file(file, scope, template)
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Tab detected. Open
filename_template = self.file_name_template(file)
- Exclude checks
Tab detected. Open
module_info = scope['module_info']
- Exclude checks
Tab detected. Open
class ContentGenerator
- Exclude checks
Tab detected. Open
file_source = IO.read(template.template_path.join(file[TEMPLATE_FILE_PATH_KEY]))
- Exclude checks
Tab detected. Open
module_info['file_name'] = file_name
- Exclude checks
Tab detected. Open
content = template.render(scope)
- Exclude checks
Line is too long. [105/80] Open
# @param template [ModuleTemplate] The model describing a Generamba template used for code generation
- Exclude checks
Tab detected. Open
file_basename = File.basename(file[TEMPLATE_FILE_NAME_KEY])
- Exclude checks
Tab detected. Open
module_info.delete('file_basename')
- Exclude checks
Tab detected. Open
def self.file_name_template(file)
- Exclude checks
Tab detected. Open
template_text = file[TEMPLATE_FILE_CUSTOM_NAME_KEY] || template_default_text
- Exclude checks
Extra empty line detected at class body beginning. Open
# Generates and returns a filename and a body of a specific code file.
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of classes match the configuration.
Example: EnforcedStyle: empty_lines
# good
class Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
class Foo
class Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
class Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
class Foo
def bar
# ...
end
end
Tab detected. Open
template = Liquid::Template.parse(file_source)
- Exclude checks
Trailing whitespace detected. Open
- Exclude checks
Line is too long. [83/80] Open
file_source = IO.read(template.template_path.join(file[TEMPLATE_FILE_PATH_KEY]))
- Exclude checks
Extra empty line detected at module body beginning. Open
# Responsible for generating code using provided liquid templates
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of modules match the configuration.
Example: EnforcedStyle: empty_lines
# good
module Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
module Foo
module Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
module Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
module Foo
def bar
# ...
end
end
Use 2 (not 1) spaces for indentation. Open
file_source = IO.read(template.template_path.join(file[TEMPLATE_FILE_PATH_KEY]))
- Read upRead up
- Exclude checks
This cops checks for indentation that doesn't use the specified number of spaces.
See also the IndentationConsistency cop which is the companion to this one.
Example:
# bad
class A
def test
puts 'hello'
end
end
# good
class A
def test
puts 'hello'
end
end
Example: IgnoredPatterns: ['^\s*module']
# bad
module A
class B
def test
puts 'hello'
end
end
end
# good
module A
class B
def test
puts 'hello'
end
end
end
Tab detected. Open
end
- Exclude checks