sparklemotion/nokogiri

View on GitHub

Showing 385 of 513 total issues

Method logicalNextDOMTextNode has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private Node logicalNextDOMTextNode(Node n)
    {
        Node p=n.getNextSibling();
        if(p==null)
        {
Severity: Minor
Found in ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java - About 1 hr 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 iconv_configure_flags has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def iconv_configure_flags
  # If --with-iconv-dir or --with-opt-dir is given, it should be
  # the first priority
  %w[iconv opt].each do |name|
    if (config = preserving_globals { dir_config(name) }).any? &&
Severity: Minor
Found in ext/nokogiri/extconf.rb - About 1 hr 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 in_context has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @JRubyMethod(required = 2, visibility = Visibility.PRIVATE)
    public IRubyObject in_context(ThreadContext context,
                                  IRubyObject str,
                                  IRubyObject options) {
        RubyModule klass;
Severity: Minor
Found in ext/java/nokogiri/XmlNode.java - About 1 hr to fix

    Method isEqualNode has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public boolean isEqualNode(Node arg) {
            if (arg == this) {
                return true;
            }
            if (arg.getNodeType() != getNodeType()) {

      Method startElement has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
              final Ruby runtime = this.runtime;
              final ThreadContext context = runtime.getCurrentContext();
      
      
      Severity: Minor
      Found in ext/java/nokogiri/internals/NokogiriHandler.java - About 1 hr to fix

        Method constructNode has 45 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
                switch (node.getNodeType()) {
                    case Node.ELEMENT_NODE:
        Severity: Minor
        Found in ext/java/nokogiri/internals/NokogiriHelpers.java - About 1 hr to fix

          Method handleAttributesSubtree has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @Override
              protected Iterator<Attr> handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
                  throws CanonicalizationException {
                  // result will contain the attrs which have to be output
                  final SortedSet<Attr> result = this.result;
          Severity: Minor
          Found in ext/java/nokogiri/internals/c14n/Canonicalizer20010315Excl.java - About 1 hr to fix

            Method getInternalSubset has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                public IRubyObject getInternalSubset(ThreadContext context) {
                    IRubyObject dtd = (IRubyObject) node.getUserData(DTD_INTERNAL_SUBSET);
            
                    if (dtd == null) {
                        Document document = getDocument();
            Severity: Minor
            Found in ext/java/nokogiri/XmlDocument.java - About 1 hr 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 op_and has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                @JRubyMethod(name="&")
                public IRubyObject op_and(ThreadContext context, IRubyObject nodeSet) {
                    IRubyObject[] otherNodes = getNodes(context, nodeSet);
            
                    if (otherNodes == null || otherNodes.length == 0) {
            Severity: Minor
            Found in ext/java/nokogiri/XmlNodeSet.java - About 1 hr 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 getXPathContext has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                private XPathContext getXPathContext(final NokogiriXPathFunctionResolver fnResolver) {
                    Node doc = context.getNode().getOwnerDocument();
                    if (doc == null) doc = context.getNode();
            
                    XPathContext xpathContext = (XPathContext) doc.getUserData(XPATH_CONTEXT);
            Severity: Minor
            Found in ext/java/nokogiri/XmlXpathContext.java - About 1 hr 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 getNamespacesWithPropagated has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                private void getNamespacesWithPropagated(List<Attr> namespaces, Attr attr) {
                    boolean newNamespace = true;
                    Iterator<Attr[]> iter = c14nNamespaceStack.iterator();
                    while (iter.hasNext()) {
                        Attr[] parentNamespaces = iter.next();
            Severity: Minor
            Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 1 hr 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 parseAttributes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                    private void parseAttributes(XMLAttributes attrs, Stack<String> langStack, Stack<String> xmlBaseStack) {
                        if (attrs.getLength() > 0) attributeList = new ReaderAttributeList();
                        String u, n, v;
                        for (int i = 0; i < attrs.getLength(); i++) {
                            u = attrs.getURI(i);
            Severity: Minor
            Found in ext/java/nokogiri/internals/ReaderNode.java - About 1 hr 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 parse has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                  def self.parse string_or_io, url = nil, encoding = nil, options = ParseOptions::DEFAULT_XML
                    options = Nokogiri::XML::ParseOptions.new(options) if Integer === options
                    # Give the options to the user
                    yield options if block_given?
            
            
            Severity: Minor
            Found in lib/nokogiri/xml/document.rb - About 1 hr 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 getDTMHandleFromNode has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @Override
                public /* synchronized */ int getDTMHandleFromNode(org.w3c.dom.Node node) {
                    //if (node == null) // "node must be non-null for getDTMHandleFromNode!");
                    //    throw new IllegalArgumentException(XMLMessages.createXMLMessage(XMLErrorResources.ER_NODE_NON_NULL, null));
                    assert node != null;
            Severity: Minor
            Found in ext/java/nokogiri/internals/XalanDTMManagerPatch.java - About 1 hr to fix

              Method enter has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public boolean enter(Element element) {
                      if (canonical) {
                          c14nNodeList.add(element);
                          if (element == element.getOwnerDocument().getDocumentElement()) {
                              c14nNodeList.add(element.getOwnerDocument());
              Severity: Minor
              Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 1 hr to fix

                Method leave has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public void leave(Node node) {
                        if (node instanceof Document) {
                            leave((Document)node);
                            return;
                        }
                Severity: Minor
                Found in ext/java/nokogiri/internals/SaveContextVisitor.java - About 1 hr to fix

                  Method extractDecls has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected IRubyObject[] extractDecls(ThreadContext context, Node node) {
                          List<IRubyObject> decls = new ArrayList<IRubyObject>();
                          while (node != null) {
                              if (isExternalSubset(node)) {
                                  break;
                  Severity: Minor
                  Found in ext/java/nokogiri/XmlDtd.java - About 1 hr to fix

                    Method getXmlnsAttr has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                            void getXmlnsAttr(Collection<Attr> col) {
                                int size = levels.size() - 1;
                                if (cur == null) {
                                    cur = new XmlsStackElement();
                                    cur.level = currentLevel;
                    Severity: Minor
                    Found in ext/java/nokogiri/internals/c14n/Canonicalizer20010315.java - About 1 hr 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 in_context has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        @JRubyMethod(required = 2, visibility = Visibility.PRIVATE)
                        public IRubyObject in_context(ThreadContext context,
                                                      IRubyObject str,
                                                      IRubyObject options) {
                            RubyModule klass;
                    Severity: Minor
                    Found in ext/java/nokogiri/XmlNode.java - About 1 hr 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 createAndCacheNamespaces has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private void createAndCacheNamespaces(Ruby ruby, Node node) {
                            if (node == null) return;
                            if (node.hasAttributes()) {
                                NamedNodeMap nodeMap = node.getAttributes();
                                for (int i=0; i<nodeMap.getLength(); i++) {
                    Severity: Minor
                    Found in ext/java/nokogiri/XmlDocument.java - About 1 hr 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