sparklemotion/nokogiri

View on GitHub

Showing 514 of 514 total issues

Method slice has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    @JRubyMethod(name={"[]", "slice"})
    public IRubyObject slice(ThreadContext context, IRubyObject indexOrRange) {
        if (indexOrRange instanceof RubyFixnum) {
          int idx = ((RubyFixnum)indexOrRange).getIntValue();

Severity: Minor
Found in ext/java/nokogiri/XmlNodeSet.java - About 25 mins to fix

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 resolveNamespaceIfNecessary has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private void resolveNamespaceIfNecessary(ThreadContext context, Node node, String default_href) {
        if (node == null) return;
        String nodePrefix = node.getPrefix();
        if (nodePrefix == null) { // default namespace
            NokogiriHelpers.renameNode(node, default_href, node.getNodeName());
Severity: Minor
Found in ext/java/nokogiri/XmlDocument.java - About 25 mins to fix

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 isVisibleDO has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected int isVisibleDO(Node currentNode, int level) {
        if (nodeFilter != null) {
            Iterator<NodeFilter> it = nodeFilter.iterator();
            while (it.hasNext()) {
                int i = (it.next()).isNodeIncludeDO(currentNode, level);
Severity: Minor
Found in ext/java/nokogiri/internals/c14n/CanonicalizerBase.java - About 25 mins to fix

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 encoding has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    @JRubyMethod
    public IRubyObject encoding(ThreadContext context) {
        if (this.encoding == null || this.encoding.isNil()) {
            if (getDocument().getXmlEncoding() == null) {
                this.encoding = context.getRuntime().getNil();
Severity: Minor
Found in ext/java/nokogiri/XmlDocument.java - About 25 mins to fix

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 delete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    @JRubyMethod
    public IRubyObject delete(ThreadContext context, IRubyObject node_or_namespace) {
        IRubyObject nodeOrNamespace = asXmlNodeOrNamespace(context, node_or_namespace);

        if (nodes.length == 0) {
Severity: Minor
Found in ext/java/nokogiri/XmlNodeSet.java - About 25 mins to fix

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 findPreviousElement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private Node findPreviousElement(Node n) {
        Node previous = n.getPreviousSibling() == null ? n.getParentNode() : n.getPreviousSibling();
        if (previous == null || previous.getNodeType() == Node.DOCUMENT_NODE) return null;
        if (previous.getNodeType() == Node.ELEMENT_NODE) {
            return previous;
Severity: Minor
Found in ext/java/nokogiri/XmlNode.java - About 25 mins to fix

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 evaluate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    @JRubyMethod
    public IRubyObject evaluate(ThreadContext context, IRubyObject expr, IRubyObject handler) {

        String src = expr.convertToString().asJavaString();
        if (!handler.isNil()) {
Severity: Minor
Found in ext/java/nokogiri/XmlXpathContext.java - About 25 mins to fix

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 root_set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    @JRubyMethod(name="root=")
    public IRubyObject root_set(ThreadContext context, IRubyObject newRoot_) {
        // in case of document fragment, temporary root node should be deleted.

        // Java can't have a root whose value is null. Instead of setting null,
Severity: Minor
Found in ext/java/nokogiri/XmlDocument.java - About 25 mins to fix

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 isVisibleInt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected int isVisibleInt(Node currentNode) {
        if (nodeFilter != null) {
            Iterator<NodeFilter> it = nodeFilter.iterator();
            while (it.hasNext()) {
                int i = (it.next()).isNodeInclude(currentNode);
Severity: Minor
Found in ext/java/nokogiri/internals/c14n/CanonicalizerBase.java - About 25 mins to fix

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 accept has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public void accept(ThreadContext context, SaveContextVisitor visitor) {
        visitor.enter(node);
        Node child = node.getFirstChild();
        while (child != null) {
Severity: Minor
Found in ext/java/nokogiri/XmlEntityReference.java - About 25 mins to fix

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 index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected int index(Object obj) {        
        Object[] set = keys;
        int length = set.length;
        //abs of index
        int index = (obj.hashCode() & 0x7fffffff) % length;
Severity: Minor
Found in ext/java/nokogiri/internals/c14n/NameSpaceSymbTable.java - About 25 mins to fix

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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected void apply(Ruby runtime, RubyClass klass,
                         XmlDocument doc,
                         NodeIter iter) {
        if (iter.isNull()) return;

Severity: Minor
Found in ext/java/nokogiri/XmlElementContent.java - About 25 mins to fix

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 createElementForFamily has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static Element createElementForFamily(Document doc, String namespace, String localName) {
        Element result;
        String prefix = ElementProxy.getDefaultPrefix(namespace);

        if (namespace == null) {
Severity: Minor
Found in ext/java/nokogiri/internals/c14n/ElementProxy.java - About 25 mins to fix

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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static StringBuffer convert(Pattern ptn, CharSequence input, String[] oldChars, String[] newChars)  {
        Matcher matcher = ptn.matcher(input);
        boolean result = matcher.find();
        StringBuffer sb = new StringBuffer(input.length() + 8);
        while (result) {
Severity: Minor
Found in ext/java/nokogiri/internals/NokogiriHelpers.java - About 25 mins to fix

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 initParser has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected void initParser(Ruby runtime) {
        if (options.xInclude) {
            System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration",
                    "org.apache.xerces.parsers.XIncludeParserConfiguration");
        }
Severity: Minor
Found in ext/java/nokogiri/internals/XmlDomParserContext.java - About 25 mins to fix

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 findEmptyTexts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static void findEmptyTexts(Node node, List<Node> emptyNodes) {
        if (node.getNodeType() == Node.TEXT_NODE && isBlank(node.getTextContent())) {
            emptyNodes.add(node);
        } else {
            NodeList children = node.getChildNodes();
Severity: Minor
Found in ext/java/nokogiri/internals/XmlDomParserContext.java - About 25 mins to fix

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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public XmlNamespace get(Node node, String prefix) {
        if (prefix == null) return defaultNamespace;
        for (String[] key : keys) {
            if (key[0].equals(prefix) && cache.get(key) != null && cache.get(key).isOwner(node)) {
                return cache.get(key).namespace;
Severity: Minor
Found in ext/java/nokogiri/internals/NokogiriNamespaceCache.java - About 25 mins to fix

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 verifyXmlSpace has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private void verifyXmlSpace(List<Attr> attributes, NamedNodeMap attrs) {
        Attr attr = (Attr) attrs.getNamedItem("xml:space");
        if (attr == null) {
            for (int i=0; i < attributes.size(); i++) {
                if (attributes.get(i).getNodeName().equals("xml:space")) {
Severity: Minor
Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 25 mins to fix

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 resolveSystemId has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private static String resolveSystemId(String baseName, String systemId) {
        if (baseName == null || baseName.length() < 1) return null;
        String parentName;
        baseName = baseName.replace("%20", " ");
        File base = new File(baseName);
Severity: Minor
Found in ext/java/nokogiri/internals/NokogiriHelpers.java - About 25 mins to fix

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 getNamespacesAndAttrs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private void getNamespacesAndAttrs(Node current, List<Attr> namespaces, List<Attr> attributes) {
        NamedNodeMap attrs = current.getAttributes();
        for (int i=0; i<attrs.getLength(); i++) {
            Attr attr = (Attr)attrs.item(i);
            if (isNamespace(attr.getNodeName())) {
Severity: Minor
Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 25 mins to fix

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

Severity
Category
Status
Source
Language