normalizedstring/normalizedstring.go
File normalizedstring.go
has 568 lines of code (exceeds 500 allowed). Consider refactoring. Open
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
NormalizedString
has 27 methods (exceeds 20 allowed). Consider refactoring. Open
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
Method NormalizedString.Split
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring. Open
Open
func (ns *NormalizedString) Split(
pattern splitpattern.SplitPattern,
behaviour SplitDelimiterBehavior,
) ([]*NormalizedString, error) {
captures, err := pattern.FindMatches(ns.normalized)
- Read upRead up
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
Open
func (ns *NormalizedString) Split(
pattern splitpattern.SplitPattern,
behaviour SplitDelimiterBehavior,
) ([]*NormalizedString, error) {
captures, err := pattern.FindMatches(ns.normalized)
Method NormalizedString.OriginalAlignments
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (ns *NormalizedString) OriginalAlignments() []AlignmentRange {
// (start, end) are in alignments
// (offset, length) are in originalAlignments
originalAlignments := make([]AlignmentRange, 0, len(ns.original))
Method NormalizedString.TransformRange
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (ns *NormalizedString) TransformRange(
rng Range,
dest []RuneChange,
initialOffset int,
) {
Method NormalizedString.CoerceRangeToOriginal
has 5 return statements (exceeds 4 allowed). Open
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
}
FIXME found Open
Open
// FIXME: it's probably wrong to pass the rune index, instead of byte index
- Exclude checks
FIXME found Open
Open
// FIXME: Append does nothing if the normalized string is empty
- Exclude checks
FIXME found Open
Open
// FIXME: Prepend does nothing if the normalized string is empty
- Exclude checks
FIXME found Open
Open
// FIXME: Go `unicode` package does not consider Unicode special casing
- Exclude checks
FIXME found Open
Open
// FIXME: see Unicode special casing notes on `NormalizedString.ToUpper()`
- Exclude checks
exported const SplitDelimiterRemoved should have comment (or a comment on this block) or be unexported Open
Open
SplitDelimiterRemoved SplitDelimiterBehavior = iota
- Exclude checks
Your code does not pass gofmt in 1 place. Go fmt your code! Open
Open
// Copyright (c) 2020, NLP Odyssey Authors. All rights reserved.
- Exclude checks