Showing 153 of 153 total issues
Method install_users
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def install_users(name:)
if (resp = existing_validation(name: name)).net_status_ok?
mapper = index[name].inheritance_mapper
# user / group
Method action_method
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def action_method(m_name, node)
params = node.instance_method(:initialize).parameters
opts = {}
params.each do |req, name|
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def _revoke(user_name:, database_name:)
user_controller = controller(User)
container_name = user_name.split('_').first
debug_operation(desc: { code: :mysql_grant, data: { database: database_name, name: user_name } }) do |&blk|
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 50.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method action
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def action
method = controller_method
opts = {}
method.parameters.each do |req, name|
next unless req.to_s.start_with? 'key'
- 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 reindex
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def reindex
self.class.index = {}
@config.muxs.grep_dirs.each do |mux_mapper|
next if mux_mapper.abstract?
name = mux_mapper.name
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def _grant(user_name:, database_name:)
user_controller = controller(User)
container_name = user_name.split('_').first
debug_operation(desc: { code: :mysql_grant, data: { database: database_name, name: user_name } }) do |&blk|
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 50.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method set_banners
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def set_banners(node = commands_hierarchy, path = [])
node.each do |k, v|
path_ = path.dup
path_ << k
if v.is_a? Hash
- 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 _add
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _add(name:, users: [], generate: false)
container_name, _db_name = @mysql_controller.alternative_name(name: name)
debug_operation(desc: { code: :mysql_database, data: { name: name } }) do |&blk|
with_dry_run do |dry_run|
- 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 copy_users
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def copy_users(name:, new_name:)
mapper = index[name].mapper
user_controller = controller(User)
container_admin_controller = admin(name: new_name)
- 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 options
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def options(name:, inheritance: false)
if (resp = existing_validation(name: name)).net_status_ok?
mapper = MapperInheritance::Model.set_inheritance(@config.models.f(name))
if inheritance
data = separate_inheritance(mapper) do |_base, inheritors|
- 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 _add
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _add(name:, databases: [], generate: false)
container_name, _user_name = @mysql_controller.alternative_name(name: name)
user_controller = controller(Controller::User)
password = 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
Block has too many lines. [33/25] Open
Gem::Specification.new do |spec|
spec.name = 'superhosting'
spec.version = Superhosting::VERSION
spec.authors = ['Alexey Igrychev', 'Timofey Kirillov', 'Dmitry Stolyarov']
spec.email = ['alexey.igrychev@flant.com', 'timofey.kirillov@flant.com', 'dmitry.stolyarov@flant.com']
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Method install_data
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def install_data(name:, model: nil)
etc_mapper = @config.containers.f(name)
if (model_ = model || etc_mapper.f('model', default: @config.default_model)).nil?
{ error: :input_error, code: :no_model_given }
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 _group_del
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _group_del(name:)
debug_operation(desc: { code: :group, data: { name: name } }) do |&blk|
with_dry_run do |dry_run|
resp = {}
if _group_get(name: name)
- 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 _group_add
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _group_add(name:)
debug_operation(desc: { code: :group, data: { name: name } }) do |&blk|
with_dry_run do |dry_run|
resp = {}
if _group_get(name: name).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 help
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def help
banners = lambda do |node|
if node.is_a? Hash
node.map do |k, v|
if v.is_a? Hash
- 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 a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _delete(name:)
container_name, _db_name = @mysql_controller.alternative_name(name: name)
index[name].each {|user_name| @mysql_controller._revoke(user_name: user_name, database_name: name) }
debug_operation(desc: { code: :mysql_database, data: { name: name } }) do |&blk|
- 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 cmd_and_node
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def cmd_and_node(args)
positional_arguments = lambda do |arr|
arr.select { |arg| arg =~ /^([[:alnum:]\_\-]+)$/ }
end
- 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 a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _delete(name:)
container_name, _user_name = @mysql_controller.alternative_name(name: name)
index[name].each { |db_name| @mysql_controller._revoke(user_name: name, database_name: db_name) }
debug_operation(desc: { code: :mysql_user, data: { name: name } }) do |&blk|
- 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
TZInfo relative path traversal vulnerability allows loading of arbitrary files Open
tzinfo (1.2.2)
- Read upRead up
- Exclude checks
Advisory: CVE-2022-31163
Criticality: High
URL: https://github.com/tzinfo/tzinfo/security/advisories/GHSA-5cm2-9h8c-rvfx
Solution: upgrade to ~> 0.3.61, >= 1.2.10