ag-gipp/MathMLTools

View on GitHub

Showing 98 of 152 total issues

Method emdHatImplLongLongInt has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

    private static long emdHatImplLongLongInt(java.util.Vector<Long> pc, java.util.Vector<Long> qc,
                                              java.util.Vector<java.util.Vector<Long>> c, long extraMassPenalty) {

        int n = pc.size();
        assert qc.size() == n;

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

def aggregate(latex):
    aggregation = []
    subgroups = [aggregation]
    insert_before_last_item = False
    environment = None
Severity: Minor
Found in mathml-converters/lib/latex2mathml/latex2mathml/aggregator.py - About 1 day 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

CMMLInfoBase has 68 methods (exceeds 20 allowed). Consider refactoring.
Open

class CMMLInfoBase {
    @SuppressWarnings("all")
    Document cmmlDoc;
    public final Node adoptNode(Node node) throws DOMException {
        return cmmlDoc.adoptNode(node);

    Method compute has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
    Open

        public long compute(java.util.Vector<Long> e, java.util.Vector<java.util.List<Edge>> c,
                            java.util.Vector<java.util.List<EdgeFlow>> x) {
            assert e.size() == c.size();
            assert x.size() == c.size();
    
    

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

    def tokenize(string):
        _buffer = ''
        environments = []
        iterable = iter(range(len(string)))
        for i in iterable:
    Severity: Minor
    Found in mathml-converters/lib/latex2mathml/latex2mathml/tokenizer.py - About 1 day 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 compactForm has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
    Open

        private static MyNode compactForm(MyNode n) {
            if (n.node.getNodeType() == Node.TEXT_NODE) {
                n.out = n.node.getNodeValue().trim();
            } else {
                n.out = n.node.getNodeName();

    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 emdHatImplLongLongInt has 163 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static long emdHatImplLongLongInt(java.util.Vector<Long> pc, java.util.Vector<Long> qc,
                                                  java.util.Vector<java.util.Vector<Long>> c, long extraMassPenalty) {
    
            int n = pc.size();
            assert qc.size() == n;

      Method computeShortestPath has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

          void computeShortestPath(java.util.Vector<Long> d, java.util.Vector<Integer> prev,
                                   int from, java.util.Vector<java.util.List<ReducedEdge>> costForward,
                                   java.util.Vector<java.util.List<ResidualReducedEdge>> costBackward,
                                   java.util.Vector<Long> e, int[] l) {
              // Making heap (all inf except 0, so we are saving comparisons...)

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

          private String generateConstraint(Node node, boolean isRoot) {
              int i = 0;
              String out = "";
              boolean hasText = false;
              if (node == null) {

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

          private String generateSimpleConstraints(Node node, boolean isRoot) {
              //Index of child node
              int childElementIndex = 0;
              final StringBuilder out = new StringBuilder();
              boolean queryHasText = false;

      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

      File XMLHelper.java has 372 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      package com.formulasearchengine.mathmltools.helper;
      
      import com.formulasearchengine.mathmltools.io.XmlDocumentReader;
      import com.formulasearchengine.mathmltools.io.XmlDocumentWriter;
      import com.formulasearchengine.mathmltools.xml.NonWhitespaceNodeList;

        Method compute has 122 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public long compute(java.util.Vector<Long> e, java.util.Vector<java.util.List<Edge>> c,
                                java.util.Vector<java.util.List<EdgeFlow>> x) {
                assert e.size() == c.size();
                assert x.size() == c.size();
        
        

          Method isIdenticalTree has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
          Open

              boolean isIdenticalTree(MathNode aTree, MathNode bTree) {
                  // first check if they have the same number of children
                  if (aTree.equals(bTree) && aTree.getChildren().size() == bTree.getChildren().size()) {
                      if (aTree.isOrderSensitive()) {
                          // all children order sensitive

          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

          File CMMLInfo.java has 364 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          package com.formulasearchengine.mathmltools.mml;
          
          import com.formulasearchengine.mathmltools.helper.XMLHelper;
          import com.formulasearchengine.mathmltools.querygenerator.FirstXQueryGenerator;
          import com.formulasearchengine.mathmltools.querygenerator.QVarXQueryGenerator;

            Function _convert_array_content has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
            Open

            def _convert_array_content(param, parent, alignment=None):
                if '|' in alignment:
                    _alignment, columnlines = [], []
                    for i in alignment:
                        if i == '|':
            Severity: Minor
            Found in mathml-converters/lib/latex2mathml/latex2mathml/converter.py - About 4 hrs 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

            XMLHelper has 33 methods (exceeds 20 allowed). Consider refactoring.
            Open

            @SuppressWarnings("UnusedDeclaration")
            public final class XMLHelper {
                public static final String NS_MATHML = "http://www.w3.org/1998/Math/MathML";
                public static final Pattern ANNOTATION_XML_PATTERN = Pattern.compile("annotation(-xml)?");
                public static final Pattern XML_DECLARATION = Pattern.compile("<\\?[xX][mM][lL].*\\?>", Pattern.DOTALL);

              Method compareNode has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static boolean compareNode(Node nQ, Node nN, Boolean considerLength, Map<String, Node> qvars) throws Exception {
                      if (qvars == null) {
                          throw new Exception("qvars array must not be null");
                      }
                      if (nQ.hasChildNodes()) {

              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

              JsonGouldiBean has 28 methods (exceeds 20 allowed). Consider refactoring.
              Open

              @SuppressWarnings("unused")
              @JsonIgnoreProperties(ignoreUnknown = true)
              @JsonPropertyOrder({
                      "definitions",
                      "constraints",

                Method abstractNodeDT has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                    private void abstractNodeDT(Node node, Integer applies) {
                        Set<String> levelGenerators = Sets.newHashSet("apply", "bind");
                        Map<String, Integer> dTa = new HashMap<>();
                        Boolean rename = false;
                        dTa.put("cn", 0);

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

                    public String toString() {
                        Node mainElement = getMainElement();
                        if (mainElement == null) {
                            return null;
                        }

                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