nlpodyssey/gotokenizers

View on GitHub
normalizedstring/normalizedstring.go

Summary

Maintainability
D
1 day
Test Coverage

File normalizedstring.go has 568 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// Copyright (c) 2020, NLP Odyssey Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package normalizedstring
Severity: Minor
Found in normalizedstring/normalizedstring.go - About 3 hrs to fix

    NormalizedString has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type NormalizedString struct {
        // The original version of the string, before any modification.
        original string
        // The normalized version of the string, after all modifications.
        normalized string
    Severity: Minor
    Found in normalizedstring/normalizedstring.go - About 3 hrs to fix

      Method NormalizedString.Split has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
      Open

      func (ns *NormalizedString) Split(
          pattern splitpattern.SplitPattern,
          behaviour SplitDelimiterBehavior,
      ) ([]*NormalizedString, error) {
          captures, err := pattern.FindMatches(ns.normalized)
      Severity: Minor
      Found in normalizedstring/normalizedstring.go - 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

      Method NormalizedString.Split has 83 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (ns *NormalizedString) Split(
          pattern splitpattern.SplitPattern,
          behaviour SplitDelimiterBehavior,
      ) ([]*NormalizedString, error) {
          captures, err := pattern.FindMatches(ns.normalized)
      Severity: Major
      Found in normalizedstring/normalizedstring.go - About 2 hrs to fix

        Method NormalizedString.OriginalAlignments has 54 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (ns *NormalizedString) OriginalAlignments() []AlignmentRange {
            // (start, end) are in alignments
            // (offset, length) are in originalAlignments
            originalAlignments := make([]AlignmentRange, 0, len(ns.original))
        
        
        Severity: Minor
        Found in normalizedstring/normalizedstring.go - About 1 hr to fix

          Method NormalizedString.TransformRange has 51 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (ns *NormalizedString) TransformRange(
              rng Range,
              dest []RuneChange,
              initialOffset int,
          ) {
          Severity: Minor
          Found in normalizedstring/normalizedstring.go - About 1 hr to fix

            Method NormalizedString.CoerceRangeToOriginal has 5 return statements (exceeds 4 allowed).
            Open

            func (ns *NormalizedString) CoerceRangeToOriginal(r Range) (OriginalRange, bool) {
                // If the string range is already in the original referential, return it as it is
                if or, isOriginal := r.(OriginalRange); isOriginal {
                    return or, true
                }
            Severity: Major
            Found in normalizedstring/normalizedstring.go - About 35 mins to fix

              FIXME found
              Open

                  // FIXME: it's probably wrong to pass the rune index, instead of byte index
              Severity: Minor
              Found in normalizedstring/normalizedstring.go by fixme

              FIXME found
              Open

              // FIXME: Append does nothing if the normalized string is empty
              Severity: Minor
              Found in normalizedstring/normalizedstring.go by fixme

              FIXME found
              Open

              // FIXME: Prepend does nothing if the normalized string is empty
              Severity: Minor
              Found in normalizedstring/normalizedstring.go by fixme

              FIXME found
              Open

              // FIXME: Go `unicode` package does not consider Unicode special casing
              Severity: Minor
              Found in normalizedstring/normalizedstring.go by fixme

              FIXME found
              Open

              // FIXME: see Unicode special casing notes on `NormalizedString.ToUpper()`
              Severity: Minor
              Found in normalizedstring/normalizedstring.go by fixme

              exported const SplitDelimiterRemoved should have comment (or a comment on this block) or be unexported
              Open

                  SplitDelimiterRemoved            SplitDelimiterBehavior = iota
              Severity: Minor
              Found in normalizedstring/normalizedstring.go by golint

              Your code does not pass gofmt in 1 place. Go fmt your code!
              Open

              // Copyright (c) 2020, NLP Odyssey Authors. All rights reserved.
              Severity: Minor
              Found in normalizedstring/normalizedstring.go by gofmt

              There are no issues that match your filters.

              Category
              Status