sparklemotion/nokogiri

View on GitHub

Showing 383 of 515 total issues

Avoid too many return statements within this method.
Open

            return XmlNodeSet.newNodeSet(runtime, ((RubyArray) obj).toJavaArray());
Severity: Major
Found in ext/java/nokogiri/internals/NokogiriXPathFunction.java - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            /*if (o instanceof XmlNode)*/ return ((XmlNode) obj).getNode();
    Severity: Major
    Found in ext/java/nokogiri/internals/NokogiriXPathFunction.java - About 30 mins to fix

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

          protected Element createElementForFamilyLocal(
              Document doc, String namespace, String localName
          ) {             
              Element result;
              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 addMapping has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public boolean addMapping(String prefix, String uri, Attr n) {                        
              NameSpaceSymbEntry ob = symb.get(prefix);        
              if ((ob != null) && uri.equals(ob.uri)) {
                  //If we have it previously defined. Don't keep working.
                  return false;
      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 addMappingAndRender has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public Node addMappingAndRender(String prefix, String uri, Attr n) {                     
              NameSpaceSymbEntry ob = symb.get(prefix);
      
              if ((ob != null) && uri.equals(ob.uri)) {
                  if (!ob.rendered) {                 
      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 getNodeName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          protected IRubyObject getNodeName(ThreadContext context) {
              if (name != null) return name;
      
              String attrName = ((Attr) node).getName();
      Severity: Minor
      Found in ext/java/nokogiri/XmlAttr.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(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 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 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 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 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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          @JRubyMethod(visibility = Visibility.PRIVATE)
          public IRubyObject get(ThreadContext context, IRubyObject rbkey) {
              if (node instanceof Element) {
                  if (rbkey == null || rbkey.isNil()) return context.nil;
                  String key = rubyStringToString(rbkey);
      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 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 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 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 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 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 isVisible has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          protected boolean isVisible(Node currentNode) {
              if (nodeFilter != null) {
                  Iterator<NodeFilter> it = nodeFilter.iterator();
                  while (it.hasNext()) {
                      if (it.next().isNodeInclude(currentNode) != 1) {
      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((Text) node);
              Node child = node.getFirstChild();
              while (child != null) {
      Severity: Minor
      Found in ext/java/nokogiri/XmlText.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 new_root) {
              // 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

      Severity
      Category
      Status
      Source
      Language