Showing 29 of 29 total issues
Class Browser
has 73 methods (exceeds 20 allowed). Consider refactoring. Open
class Browser
def initialize(connection)
@connection = connection
apply_defaults
end
Class Driver
has 69 methods (exceeds 20 allowed). Consider refactoring. Open
class Driver < Capybara::Driver::Base
def initialize(app, options={})
@app = app
@options = options.dup
@options[:server] ||= Server.new(options)
File capybara.js
has 477 lines of code (exceeds 250 allowed). Consider refactoring. Open
Capybara = {
nextIndex: 0,
nodes: {},
attachedFiles: [],
keyModifiersStack: [],
`` has 51 functions (exceeds 20 allowed). Consider refactoring. Open
Capybara = {
nextIndex: 0,
nodes: {},
attachedFiles: [],
keyModifiersStack: [],
File driver.rb
has 388 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "capybara"
require "capybara/webkit/version"
require "capybara/webkit/node"
require "capybara/webkit/connection"
require "capybara/webkit/browser"
Class Node
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
class Node < Capybara::Driver::Node
def initialize(driver, base, browser)
super(driver, base)
@browser = browser
end
File browser.rb
has 291 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "json"
require "capybara/webkit/errors"
module Capybara::Webkit
class Browser
Function set
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
set: function (index, value) {
var length, maxLength, node, strindex, textTypes, type;
node = this.getNode(index);
type = (node.type || node.tagName).toLowerCase();
- 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
Function getXPathNode
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
getXPathNode: function(node, path) {
path = path || [];
if (node.parentNode) {
path = this.getXPathNode(node.parentNode, 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
Function wrapResult
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
wrapResult: function(arg) {
if (this._visitedObjects.indexOf(arg) >= 0) { return '(cyclic structure)'; }
if (arg instanceof NodeList) { arg = Array.prototype.slice.call(arg, 0); }
if (Array.isArray(arg)) {
for(var _j = 0; _j < arg.length; _j++) {
- 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
Function _sendKeys
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
_sendKeys: function(keys) {
if (typeof keys == "string") {
var str_len = keys.length;
var str_idx;
for (str_idx = 0; str_idx < str_len; str_idx++) {
- 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 convert_to_named_keys
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def convert_to_named_keys(key)
if key.is_a? Array
key.map { |k| convert_to_named_keys(k)}
else
case key
Function set
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
set: function (index, value) {
var length, maxLength, node, strindex, textTypes, type;
node = this.getNode(index);
type = (node.type || node.tagName).toLowerCase();
Method kill_process
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def kill_process
if @pid
if RUBY_PLATFORM =~ /mingw32/
Process.kill(9, @pid)
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (rect.width > 0 && rect.height > 0)
return CapybaraInvocation.clickPosition(node, rect.left, rect.top, rect.width, rect.height);
- 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 55.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (rect.width > 0 && rect.height > 0)
return CapybaraInvocation.clickPosition(node, rect.left, rect.top, rect.width, rect.height);
- 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 55.
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
Function clickPosition
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
clickPosition: function(node) {
if(node.namespaceURI == 'http://www.w3.org/2000/svg') {
var rect = node.getBoundingClientRect();
if (rect.width > 0 && rect.height > 0)
- 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 []
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def [](name)
name = name.to_s
tn = tag_name
if (tn == "img" && name == "src") || (tn == "a" && name == "href")
# Although the attribute matters, the property is consistent. Return that in
- 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 apply_options
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def apply_options
if @options[:debug]
@browser.enable_logging
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 switch_to_frame
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def switch_to_frame(frame)
case frame
when :top
begin
loop { @browser.frame_focus }
- 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"