Showing 537 of 537 total issues
Method getXmlBaseUri
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
private String
getXmlBaseUri(String n, String v, Stack<String> xmlBaseStack)
{
if ("xml:base".equals(n)) {
if (v.startsWith("http://")) {
- 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 parse
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def parse(
string_or_io,
url_ = nil, encoding_ = nil, options_ = XML::ParseOptions::DEFAULT_XML,
url: url_, encoding: encoding_, options: options_
)
- 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 visit_element_name
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def visit_element_name(node)
if @doctype == DoctypeConfig::HTML5 && html5_element_name_needs_namespace_handling(node)
# HTML5 has namespaces that should be ignored in CSS queries
# https://github.com/sparklemotion/nokogiri/issues/2376
if @builtins == BuiltinsConfig::ALWAYS || (@builtins == BuiltinsConfig::OPTIMAL && Nokogiri.uses_libxml?)
- 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 constructNode
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static IRubyObject
constructNode(Ruby runtime, Node node)
{
if (node == null) { return runtime.getNil(); }
// this is slow; need a way to cache nokogiri classes/modules somewhere
Method relink_namespace
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public void
relink_namespace(ThreadContext context)
{
if (!(node instanceof Element)) {
return;
XmlSaxParserContext
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
@JRubyClass(name = "Nokogiri::XML::SAX::ParserContext")
public class XmlSaxParserContext extends ParserContext
{
private static final long serialVersionUID = 1L;
Method node_type
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
@JRubyMethod(name = {"node_type", "type"})
public IRubyObject
node_type(ThreadContext context)
{
String type;
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (output.length() == 0) {
output.append("/");
} else if (output.toString().endsWith("../")) {
output.append("..");
} else if (output.toString().endsWith("..")) {
- 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 138.
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 (output.length() == 0) {
output.append("/");
} else if (output.toString().endsWith("../")) {
output.append("..");
} else if (output.toString().endsWith("..")) {
- 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 138.
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 handleParent
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
@Override
protected void
handleParent(Element e, NameSpaceSymbTable ns)
{
if (!e.hasAttributes() && e.getNamespaceURI() == null) {
- 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 writeStringToUtf8
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public static void
writeStringToUtf8(
final String str,
final OutputStream out
) throws IOException
- 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 logicalNextDOMTextNode
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private Node
logicalNextDOMTextNode(Node n)
{
Node p = n.getNextSibling();
if (p == null) {
- 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 getAttributesWithPropagated
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
private void
getAttributesWithPropagated(List<Attr> attributes, Attr attr)
{
boolean newAttribute = true;
Iterator<Attr[]> iter = c14nAttrStack.iterator();
- 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 nth
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def nth(node, options = {})
unless node.value.size == 4
raise(ArgumentError, "expected an+b node to contain 4 tokens, but is #{node.value.inspect}")
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 adoptAs
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected IRubyObject
adoptAs(ThreadContext context, AdoptScheme scheme, IRubyObject other_)
{
final XmlNode other = asXmlNode(context, other_);
// this.doc might be null since this node can be empty node.
Method getStringInUtf8
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static byte[]
getStringInUtf8(final String str)
{
final int length = str.length();
boolean expanded = false;
Method createXmlModule
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
private RubyClass
createXmlModule(Ruby ruby, RubyModule xmlModule)
{
RubyClass node = xmlModule.defineClassUnder("Node", ruby.getObject(), XML_NODE_ALLOCATOR);
node.defineAnnotatedMethods(XmlNode.class);
Method circumventBug2650internal
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
@SuppressWarnings("fallthrough")
private static void
circumventBug2650internal(Node node)
{
Node parent = null;
Method lookupNamespaceURI
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public String
lookupNamespaceURI(String specifiedPrefix)
{
short type = this.getNodeType();
switch (type) {
Method canonicalize
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
@JRubyMethod(optional = 3)
public IRubyObject
canonicalize(ThreadContext context, IRubyObject[] args, Block block)
{
int mode = 0;