Showing 336 of 336 total issues
Method url_for
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def url_for(params)
host_with_port = host || location.host
host_with_port += ":#{port}" if port && port != 80
scheme = scheme || location.scheme
Method initialize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(handler, path, tag_name, attributes, unary)
super(handler, path)
@binding_in_path = path
Method changed
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def changed(attribute_name = nil)
path = @model.path
promise = Promise.new
Method write_files_and_manifest
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def write_files_and_manifest
asset_files = AssetFiles.from_cache(@volt_app.app_url, 'main', @volt_app.component_paths)
# Write a temp css file
js = asset_files.javascript(@volt_app)
css = asset_files.css
Similar blocks of code found in 2 locations. Consider refactoring. Open
preventDefault: function() {
var e = this.originalEvent;
this.isDefaultPrevented = returnTrue;
- 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 57.
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
stopPropagation: function() {
var e = this.originalEvent;
this.isPropagationStopped = returnTrue;
- 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 57.
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 get
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get(attr_name, expand = false)
# Reading an attribute, we may get back a nil model.
attr_name = attr_name.to_sym
check_valid_field_name(attr_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 initialize
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def initialize(builder, app_url, app_path, component_paths)
Opal::Processor.source_map_enabled = Volt.source_maps?
Opal::Processor.const_missing_enabled = true
# Setup Opal paths
- 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 initialize
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def initialize
# rbnacl is not supported on windows.
windows = Gem.win_platform?
if windows
- 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 duration_in_words
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def duration_in_words(places=2, min_unit=:minutes, recent_message='just now')
parts = []
secs = to_i
UNIT_MAP.each_pair do |unit, count|
val = (secs / count).floor
- 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 filtered_attributes
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def filtered_attributes
# Run the read permission check
allow_and_deny_fields(:read).then do |allow, deny|
result = 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 components
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def components
return @components if @components
@components = {}
app_folders do |app_folder|
- 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 validate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.validate(model, field_name, args)
if RUBY_PLATFORM != 'opal'
if args
value = model.get(field_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 start_message_bus
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def start_message_bus
return if ENV['NO_MESSAGE_BUS']
unless RUBY_PLATFORM == 'opal'
- 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 connect!
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def connect!
# The websocket url can be overridden by config.public.websocket_url
socket_url = Volt.config.try(:public).try(:websocket_url) || begin
"#{`document.location.host`}/socket"
end
Function fix
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
fix: function( event ) {
if ( event[ jQuery.expando ] ) {
return event;
}
Function propFilter
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function propFilter( props, specialEasing ) {
var index, name, easing, value, hooks;
// camelCase, specialEasing and expand cssHook pass
for ( index in props ) {
Method rezero_bindings
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def rezero_bindings(html, bindings)
@@base_binding_id ||= 20_000
# rezero
parts = html.split(/(\<\!\-\- \$\/?[0-9]+ \-\-\>)/).reject { |v| v == '' }
Method filtered_attributes
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def filtered_attributes
# Run the read permission check
allow_and_deny_fields(:read).then do |allow, deny|
result = nil
Method initialize
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(thor, name, options)
@thor = thor
@component_name = name.chomp('/')
@name = 'volt-' + @component_name # remove trailing slash if present
@shell = Thor::Base.shell.new