ReanGD/go-morphy

View on GitHub

Showing 10 of 10 total issues

Method Completer.next has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
Open

func (c *Completer) next() bool {
    lenIndexStack := len(c.indexStack)
    if lenIndexStack == 0 {
        return false
    }
Severity: Minor
Found in dawg/completer.go - 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    for curPos, bStep := range key[startPos:] {
        ReplaceChar, ok := replaceChars[bStep]

        if ok {
            nextIndex, ok := d.dct.followBytes([]byte(string(ReplaceChar)), index)
Severity: Major
Found in dawg/record_dawg.go and 1 other location - About 1 hr to fix
dawg/dawg.go on lines 53..70

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 157.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    for curPos, bStep := range key[startPos:] {
        ReplaceChar, ok := replaceChars[bStep]

        if ok {
            nextIndex, ok := d.dct.followBytes([]byte(string(ReplaceChar)), index)
Severity: Major
Found in dawg/dawg.go and 1 other location - About 1 hr to fix
dawg/record_dawg.go on lines 71..88

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 157.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid deeply nested control flow statements.
Open

                    if !ok {
                        return false
                    }
Severity: Major
Found in dawg/completer.go - About 45 mins to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (d *BytesDAWG) Get(key string) ([][]byte, bool) {
        index, ok := d.followKey([]byte(key))
        if !ok {
            return [][]byte{}, false
        }
    Severity: Minor
    Found in dawg/bytes_dawg.go and 1 other location - About 35 mins to fix
    dawg/record_dawg.go on lines 21..29

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 106.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (d *RecordDAWG) Get(key string) ([][]uint16, bool) {
        index, ok := d.followKey([]byte(key))
        if !ok {
            return [][]uint16{}, false
        }
    Severity: Minor
    Found in dawg/record_dawg.go and 1 other location - About 35 mins to fix
    dawg/bytes_dawg.go on lines 30..38

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 106.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method Completer.next has 5 return statements (exceeds 4 allowed).
    Open

    func (c *Completer) next() bool {
        lenIndexStack := len(c.indexStack)
        if lenIndexStack == 0 {
            return false
        }
    Severity: Major
    Found in dawg/completer.go - About 35 mins to fix

      This redirection doesn't have a command. Move to its command (or use 'true' as no-op).
      Open

      > coverage.txt
      Severity: Minor
      Found in .test.sh by shellcheck

      This redirection doesn't have a command. Move to its command (or use 'true' as no-op).

      Problematic code:

      { 
        echo "Report for $(date +%F)"
        uptime
        df -h
      }
        > report.txt

      Correct code:

      { 
        echo "Report for $(date +%F)"
        uptime
        df -h
      } > report.txt

      Rationale:

      ShellCheck found a redirection that doesn't actually redirect from/to anything.

      This could indicate a bug, such as in the problematic code where an additional linefeed causes report.txt to be truncated instead of containing report output, or in foo & > bar, where either foo &> bar or foo > bar & was intended.

      However, it could also be intentionally used to truncate a file or check that it's readable. You can make this more explicit for both ShellCheck and human readers by using true or : as a dummy command, e.g. true > file or : > file.

      Exceptions:

      There are no semantic problems with using > foo over true > foo, so if you don't see this as a potential source of bugs or confusion, you can [[ignore]] it.

      Notice

      Original content from the ShellCheck https://github.com/koalaman/shellcheck/wiki.

      Line length
      Open

      Порт морфологического анализатора [pymorphy2](https://github.com/kmike/pymorphy2) ([v0.8](https://github.com/kmike/pymorphy2/releases/tag/0.8)) и его составной части [DAWG-Python](https://github.com/pytries/DAWG-Python) ([v0.7.2](https://github.com/pytries/DAWG-Python/releases/tag/0.7.2)) на Golang.
      Severity: Info
      Found in README.md by markdownlint

      MD013 - Line length

      Tags: line_length

      Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)

      This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.

      This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.

      You also have the option to exclude this rule for code blocks and tables. To do this, set the code_blocks and/or tables parameters to false.

      Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.

      2: cannot find package "github.com/ReanGD/go-morphy/dawg" in any of:
      Open

          "github.com/ReanGD/go-morphy/dawg"
      Severity: Minor
      Found in benchmarks/utils.go by govet
      Severity
      Category
      Status
      Source
      Language