megagonlabs/desuwa

View on GitHub

Showing 21 of 21 total issues

Function match has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    def match(self, mylist: List, position: int, span_start: int, span_end: int) -> bool:
        assert 0 <= span_start <= span_end < len(mylist)
        rule_num = len(self)

        if self.forward:
Severity: Minor
Found in desuwa/rule/template.py - About 6 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

Function parse has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

def parse(tags: Tags) -> Iterator[str]:
    for tag in tags:
        pred_type_set = tag.fs.get_by_key("用言")
        if pred_type_set is None:
            continue
Severity: Minor
Found in desuwa/predicate.py - About 5 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

Function main has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

def main() -> None:
    opts = get_opts()
    ruler = RulerMrph([RulesLevelMrph(r_path) for r_path in opts.mrphrule])
    tag_ruler = None
    if opts.tagrule:
Severity: Minor
Found in desuwa/cli.py - About 3 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

Function __init__ has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, constraint: List[Union[Symbol, List[Symbol]]]):
        rexp_str_list: List[str] = []
        self._feature_constraints: Optional[FeatureConstraints] = None

        def _deny(e: str) -> str:
Severity: Minor
Found in desuwa/rule/mrph.py - About 2 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

Function match has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def match(self, mylist: List, target: int) -> bool:
        if self.prev_constraints:
            if target - 1 < 0:
                return False
            _matched = self.prev_constraints.match(mylist, target - 1, 0, target - 1)
Severity: Minor
Found in desuwa/rule/template.py - 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

Function __init__ has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def __init__(self, constraints: List[List[Union[Symbol, List[Symbol]]]], forward: bool):
        self.forward = forward
        self.denies: Set[int] = set()
        self.minimum: List[Optional[int]] = []
        for constraint in constraints:
Severity: Minor
Found in desuwa/rule/template.py - 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

Function match has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def match(self, mlist: MList, idx: int) -> bool:
        mrph = mlist[idx]
        if not hasattr(mrph, "fs"):
            mrph.fs = Features()

Severity: Minor
Found in desuwa/rule/mrph.py - 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

Function initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(mlist: MList):
        if hasattr(mlist, "fs_inited"):
            return
        mlist.fs_inited = True

Severity: Minor
Found in desuwa/rule/rule_mrph.py - 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

Function discard has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def discard(self, name: str):
        if name in self.values:
            self.values.remove(name)
            _sep = name.find(":")
            if _sep >= 0:
Severity: Minor
Found in desuwa/rule/__init__.py - About 55 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

Function apply has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def apply(self, mylist: List, index: int):
        _matched = self.match(mylist, index)
        if not _matched:
            return
        for j in range(index, index + self._center_len):
Severity: Minor
Found in desuwa/rule/template.py - About 45 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

Function loads_tags has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def loads_tags(text: str) -> Tags:
    tags_fss: List[Features] = []
    mrph_fss: List[Features] = []
    indices = []
    idx = 0
Severity: Minor
Found in desuwa/rule/__init__.py - About 45 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

Avoid too many return statements within this function.
Open

            return False
Severity: Major
Found in desuwa/rule/template.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                        return False
    Severity: Major
    Found in desuwa/rule/template.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return True
      Severity: Major
      Found in desuwa/rule/template.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return True
        Severity: Major
        Found in desuwa/rule/template.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return False
          Severity: Major
          Found in desuwa/rule/template.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return True
            Severity: Major
            Found in desuwa/rule/template.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return False
              Severity: Major
              Found in desuwa/rule/template.py - About 30 mins to fix

                Function __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    def __init__(self, text: str):
                        self.text = text
                        _s = sexpdata.loads(clean_sexp(text))
                        assert len(_s) >= 4
                        self._center_len = 1
                Severity: Minor
                Found in desuwa/rule/template.py - 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

                Function parse_rule_text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def parse_rule_text(inf: IO) -> Iterator[str]:
                    p_num = 0
                    buf = ""
                    for line in inf:
                        line = line[: line.find(";")].strip()
                Severity: Minor
                Found in desuwa/rule/util.py - 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