Showing 115 of 227 total issues
Function addElement
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
ElementQueue.prototype.addElement = function(e) {
var eq = this;
// We keep track of which elements
// are followed by others, so we can rapidly
// decide which ones needs adjusting in the queue
Function Scraper
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
var Scraper = function(definition, headless) {
var scraper = this;
EventEmitter2.call(this, {
wildcard: true,
Function id
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Functions.id = function() {
var c = arguments[0];
var id;
if (arguments.length != 2) {
throw new Error("Function id expects (object)");
- 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 getOwnerElement
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
PathExpr.prototype.getOwnerElement = function(n) {
// DOM 2 has ownerElement
if (n.ownerElement) {
return n.ownerElement;
}
- 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 coalesceText
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Utilities.coalesceText = function(n) {
for (var m = n.firstChild; m != null; m = m.nextSibling) {
if (m.nodeType == 3 /*Node.TEXT_NODE*/ || m.nodeType == 4 /*Node.CDATA_SECTION_NODE*/) {
var s = m.nodeValue;
var first = m;
Function addStandardFunctions
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
FunctionResolver.prototype.addStandardFunctions = function() {
this.functions["{}last"] = Functions.last;
this.functions["{}position"] = Functions.position;
this.functions["{}count"] = Functions.count;
this.functions["{}id"] = Functions.id;
Function translate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Functions.translate = function() {
var c = arguments[0];
if (arguments.length != 4) {
throw new Error("Function translate expects (string, string, string)");
}
Function runRegex
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Scraper.prototype.runRegex = function(string, regex) {
var re;
if (regex instanceof Object) {
if (regex.flags) {
var flags = regex.flags.join('');
- 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 checkUrl
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
url.checkUrl = function(theUrl) {
var protocol = /^(f|ht)tps?:\/\//i.test(theUrl);
var domain = /:\/\/\w+(\.[^:]+)*([:\/].+)*$/i.test(theUrl);
if (!protocol || !domain) {
// not a valid URL
- 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 addElement
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
ElementQueue.prototype.addElement = function(e) {
var eq = this;
// We keep track of which elements
// are followed by others, so we can rapidly
// decide which ones needs adjusting in the queue
- 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
Avoid deeply nested control flow statements. Open
if (!e.selector) {
problems.push('element ' + k + ' has no selector');
}
Avoid deeply nested control flow statements. Open
while (c >= '0' && c <= '9') {
number += c;
c = s.charAt(pos++);
}
Avoid deeply nested control flow statements. Open
while (Utilities.isNCNameChar(c.charCodeAt(0))) {
name += c;
c = s.charAt(pos++);
}
Function getChildElements
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getChildElements(obj) {
var elementsArray = [];
// process followables first, they
// will be excluded from results later
if (obj.followables) {
- 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
Avoid deeply nested control flow statements. Open
do {
for (var m = st.pop(); m != null; ) {
if (step.nodeTest.matches(m, xpc)) {
newNodes.push(m);
}
Avoid deeply nested control flow statements. Open
if (xpc.virtualRoot != null) {
st = [ xpc.virtualRoot ];
} else {
st = xpc.contextNode.nodeType == 9 /*Node.DOCUMENT_NODE*/
? [ xpc.contextNode ]
Avoid deeply nested control flow statements. Open
if (name == "div") {
types.push(XPathParser.DIV);
values.push(name);
continue;
}
Avoid deeply nested control flow statements. Open
if (xpc.contextNode.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) {
m = this.getOwnerElement(xpc.contextNode);
} else {
m = xpc.contextNode.parentNode;
}
Avoid deeply nested control flow statements. Open
if (xpc.contextNode !== xpc.virtualRoot) {
if (xpc.contextNode.nodeType == 2 /*Node.ATTRIBUTE_NODE*/) {
m = this.getOwnerElement(xpc.contextNode);
} else {
m = xpc.contextNode.parentNode;
Avoid deeply nested control flow statements. Open
if (m != null && step.nodeTest.matches(m, xpc)) {
newNodes.push(m);
}