Showing 72 of 72 total issues
Class Lexer
has 53 methods (exceeds 20 allowed). Consider refactoring. Open
class Lexer < Ripper::Lexer
include CompositeObservable
include LexerConstants
include LogSwitch::Mixin
Method parse!
has 169 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.parse!(args)
register_custom_option_types
options = OpenStruct.new
options.config_file = ''
options.output_file = ''
Similar blocks of code found in 2 locations. Consider refactoring. Open
class Tailor
module Rulers
# Checks for spaces before a +)+ as given by +@config+. It skips checking
# when:
- 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 130.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
class Tailor
module Rulers
# Checks for spaces before a +]+ as given by +@config+. It skips checking
# when:
- 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 130.
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
File lexer.rb
has 319 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'ripper'
require_relative 'composite_observable'
require_relative 'lexed_line'
require_relative 'lexer/lexer_constants'
require_relative 'logger'
Method define_observer
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def self.define_observer(name)
define_method("add_#{name}_observer") do |observer|
@notifiers = {} unless defined? @notifiers
@notifiers[name] = {} unless @notifiers[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 check_spaces_after_comma
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def check_spaces_after_comma(lexed_line, lineno)
log "Commas found at: #{@comma_columns}" unless @comma_columns.empty?
@comma_columns.each do |c|
event_index = lexed_line.event_index(c)
- 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
Class IndentationSpacesRuler
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class IndentationSpacesRuler < Tailor::Ruler
def initialize(config, options)
super(config, options)
add_lexer_observers(
:comment,
Class LexedLine
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class LexedLine < Array
include LexerConstants
def initialize(lexed_file, lineno)
@lineno = lineno
Class IndentationManager
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class IndentationManager
include Tailor::LexerConstants
include Tailor::Logger::Mixin
# These are event names generated by the {Lexer} that signify
Method build_xml
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def build_xml(node, doc = nil, xml_node=nil)
doc, xml_node = xml_document(doc, xml_node)
if node.respond_to?(:each)
# First child is the node 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 count_spaces
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def count_spaces(lexed_line, column)
event_index = lexed_line.event_index(column)
if event_index.nil?
log 'No lbracket in this line. Moving on...'
Method count_spaces
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def count_spaces(lexed_line, column)
event_index = lexed_line.event_index(column)
if event_index.nil?
log 'No lparen in this line. Moving on...'
Similar blocks of code found in 2 locations. Consider refactoring. Open
def ignored_nl_update(lexed_line, _, _)
return if @method_start_lines.empty?
return if lexed_line.only_spaces?
return if lexed_line.comment_line?
- 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 56.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def ignored_nl_update(lexed_line, _, _)
return if @class_start_lines.empty?
return if lexed_line.only_spaces?
return if lexed_line.comment_line?
- 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 56.
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 modifier_keyword?
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def modifier_keyword?
return false unless keyword_to_indent?
line_of_text = @options[:full_line_of_text]
log "Line of text: #{line_of_text}"
- 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 count_spaces
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def count_spaces(lexed_line, column)
current_index = lexed_line.event_index(column)
log "Current event index: #{current_index}"
previous_event = lexed_line.at(current_index - 1)
log "Previous event: #{previous_event}"
Method modifier_keyword?
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def modifier_keyword?
return false unless keyword_to_indent?
line_of_text = @options[:full_line_of_text]
log "Line of text: #{line_of_text}"
Method check_spaces_after_comma
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_spaces_after_comma(lexed_line, lineno)
log "Commas found at: #{@comma_columns}" unless @comma_columns.empty?
@comma_columns.each do |c|
event_index = lexed_line.event_index(c)
Method count_spaces
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def count_spaces(lexed_line, column)
event_index = lexed_line.event_index(column)
if event_index.nil?
log 'No lbrace in this line. Moving on...'