Showing 159 of 159 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
func (msmsi MapStringMapStringInt) Add(str1, str2 string, val int) {
if _, ok := msmsi[str1]; !ok {
msmsi[str1] = map[string]int{}
}
if _, ok := msmsi[str1][str2]; !ok {
- Read upRead up
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 117.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
func MinMaxUint(vals ...uint) (uint, uint) {
min := uint(0)
max := uint(0)
for i, val := range vals {
if i == 0 {
- Read upRead up
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 116.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
func MinMaxInt32(vals ...int32) (int32, int32) {
min := int32(0)
max := int32(0)
for i, val := range vals {
if i == 0 {
- Read upRead up
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 116.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method Request.BodyBytes
has 7 return statements (exceeds 4 allowed). Open
func (req *Request) BodyBytes() ([]byte, error) {
if req.Body == nil {
return []byte{}, nil
} else if reqBodyBytes, ok := req.Body.([]byte); ok {
return reqBodyBytes, nil
Function ReadDirRxSubmatch
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func ReadDirRxSubmatch(dir string, rx *regexp.Regexp, subMatchIdx uint, inclDirs, inclFiles, inclEmptyFiles bool) (map[string][]os.DirEntry, error) {
entryMap := map[string][]os.DirEntry{}
entries, err := os.ReadDir(dir)
if err != nil {
- 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
Function Filenames
has 7 return statements (exceeds 4 allowed). Open
func Filenames(name string, rx *regexp.Regexp, inclEmptyFiles, absPath bool) ([]string, error) {
isFile, err := IsFile(name, !inclEmptyFiles)
if err != nil {
return []string{}, err
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
func FilenModAgeGTE(filename string, s string) (bool, error) {
ageCheck, err := time.ParseDuration(s)
if err != nil {
return false, err
}
- Read upRead up
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 115.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
func FileModAgeLTE(filename string, s string) (bool, error) {
ageCheck, err := time.ParseDuration(s)
if err != nil {
return false, err
}
- Read upRead up
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 115.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid deeply nested control flow statements. Open
} else if valFloat, ok := v.(float64); ok {
return valFloat != 0.0
}
Avoid deeply nested control flow statements. Open
} else if valFloat, ok := v.(float64); ok {
return int(valFloat)
} else {
return defaultValue
}
Avoid deeply nested control flow statements. Open
} else if endDd.MatchLeft(tok, nil) {
curDesc.Description = append(curDesc.Description, tok)
dl = append(dl, curDesc)
matching = ""
curDesc = Description{}
Avoid deeply nested control flow statements. Open
if opts.InclusiveMatch {
matches = append(matches, tok)
}
Function SeverityInclude
has 7 return statements (exceeds 4 allowed). Open
func SeverityInclude(filterLevel, itemLevel string) (bool, error) {
filterLevelGood, err := Parse(filterLevel)
if err != nil || filterLevelGood == SeverityDisabled {
return false, err
}
Avoid deeply nested control flow statements. Open
} else if extLeft != nil {
return BuildBinsDurationLeftRight(*extLeft, durs[0])
} else {
return BuildBinsDurationLeftRight(durs[0], *extRight)
}
Avoid deeply nested control flow statements. Open
} else if units == "y" {
s = fmt.Sprintf("%vs", i*YearSeconds)
} else {
return zeroDuration, errors.New("timeutil.ParseDuration Parse Error")
}
Avoid deeply nested control flow statements. Open
if opts.InclusiveMatch {
matches = append(matches, tok)
}
Avoid deeply nested control flow statements. Open
} else if req.BodyType == BodyTypeXML {
return xmlutil.MarshalIndent(req.Body, "", "", req.AddXMLDocType)
} else if req.BodyType == BodyTypeForm {
if v, ok := req.Body.(url.Values); ok {
return []byte(v.Encode()), nil
Avoid deeply nested control flow statements. Open
} else if opts.IncludeChain {
matches = append(matches, tok)
}
Avoid deeply nested control flow statements. Open
} else if !stringsutil.UniqueRunes(a2) {
return errors.New("alphabet 2 chars are not unique")
}
Avoid deeply nested control flow statements. Open
} else if bl, ok := a.(bool); ok {
if bl {
*s = String("true")
} else {
*s = String("false")