Showing 96 of 96 total issues
Function GetCSP
has 80 lines of code (exceeds 50 allowed). Consider refactoring. Open
func GetCSP() string {
csp := ""
if _, err := os.Stat(dmiDir); os.IsNotExist(err) {
InfoLog("directory '%s' does not exist", dmiDir)
Function CheckRpmVers
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
func CheckRpmVers(vers1, vers2 string) int {
// per definition numbers are greater than alphas
if vers1 == vers2 {
return 0
}
- 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 printNoteAndSols
has 74 lines of code (exceeds 50 allowed). Consider refactoring. Open
func printNoteAndSols(writer io.Writer, tuneApp *app.App, jstat *system.JStatus) bool {
notTuned := true
partial := false
fmt.Fprintf(writer, "enabled Solution: ")
solName := ""
Function main
has 73 lines of code (exceeds 50 allowed). Consider refactoring. Open
func main() {
system.InitOut(logSwitch)
if !system.ChkCliSyntax() {
actions.PrintHelpAndExit(os.Stdout, 1)
}
Method INISettings.Initialise
has 70 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (vend INISettings) Initialise() (Note, error) {
ini, err := txtparser.GetSectionInfo("sns", vend.ID, false)
if err != nil {
// Parse the configuration file
ini, err = txtparser.ParseINIFile(vend.ConfFilePath, false)
Function printSolAnalysis
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
func printSolAnalysis(writer io.Writer, stageName, txtPrefix, flag string) (bool, int) {
releaseable := true
retVal := 0
txtDeleteSol := "Deletion of %s\n"
txtSolNew := txtPrefix + "Solution is new, no action required.\n"
Function PrintNoteFields
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
func PrintNoteFields(writer io.Writer, header string, noteComparisons map[string]map[string]note.FieldComparison, printComparison bool, result *system.JPNotes) {
// initialise
colFormat := ""
colCompliant := ""
compliant := "yes"
Function stagingActionRelease
has 67 lines of code (exceeds 50 allowed). Consider refactoring. Open
func stagingActionRelease(reader io.Reader, writer io.Writer, sObject []string) {
for _, sName := range sObject {
stagingFile := stgFiles.StageAttributes[sName]["sfilename"]
stageVers := stgFiles.StageAttributes[sName]["version"]
stageDate := stgFiles.StageAttributes[sName]["date"]
Method INISettings.Apply
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (vend INISettings) Apply() error {
var err error
errs := make([]error, 0)
revertValues := false
pvendID := vend.ID
Function printNoteAnalysis
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
func printNoteAnalysis(writer io.Writer, stageName, txtPrefix, flag string) (bool, int) {
releaseable := true
retVal := 0
txtDeleteNote := "Deletion of %s\n"
txtOverrideExists := txtPrefix + "Override file exists and might need adjustments.\n"
Function SolutionActionList
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
func SolutionActionList(writer io.Writer, tuneApp *app.App) {
jsolutionList := []system.JSolListEntry{}
jsolutionListEntry := system.JSolListEntry{}
setColor := false
fmt.Fprintf(writer, "\nAll solutions (* denotes enabled solution, O denotes override file exists for solution, C denotes custom solutions, D denotes deprecated solutions):\n")
Function GetFLInfo
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func GetFLInfo() (string, string, bool) {
lat := 0
maxlat := 0
supported := false
savedStates := ""
- 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 PrintStageFields
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func PrintStageFields(writer io.Writer, stageName string, comparison map[string]stageComparison) {
workFile := stgFiles.StageAttributes[stageName]["wfilename"]
headWork := fmt.Sprintf("Version %s (%s) ", txtparser.GetINIFileVersionSectionEntry(workFile, "version"), txtparser.GetINIFileVersionSectionEntry(workFile, "date"))
headStage := fmt.Sprintf("Version %s (%s) ", stgFiles.StageAttributes[stageName]["version"], stgFiles.StageAttributes[stageName]["date"])
- 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 printNoteAnalysis
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func printNoteAnalysis(writer io.Writer, stageName, txtPrefix, flag string) (bool, int) {
releaseable := true
retVal := 0
txtDeleteNote := "Deletion of %s\n"
txtOverrideExists := txtPrefix + "Override file exists and might need adjustments.\n"
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
func chkForceFlag(cmdLinePos map[string]int) bool {
stArgs := os.Args
ret := true
if IsFlagSet("force") {
if !(stArgs[cmdLinePos["realm"]] == "solution" && stArgs[cmdLinePos["cmd"]] == "change") && !(stArgs[cmdLinePos["realm"]] == "staging" && stArgs[cmdLinePos["cmd"]] == "release") {
- 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 164.
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 chkServiceStatusSyntax(cmdLinePos map[string]int) bool {
stArgs := os.Args
ret := true
if IsFlagSet("non-compliance-check") {
// saptune service status --non-compliance-check
- 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 164.
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
Function CheckRpmVers
has 14 return statements (exceeds 4 allowed). Open
func CheckRpmVers(vers1, vers2 string) int {
// per definition numbers are greater than alphas
if vers1 == vers2 {
return 0
}
Function GetSysSearchParam
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func GetSysSearchParam(syskey string) (string, string) {
searchParam := ""
sect := ""
// blkdev
sched := regexp.MustCompile(`block.*queue\.scheduler$`)
Function OptServiceVal
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func OptServiceVal(key, cfgval string) string {
ssState := false
edState := false
retVal := ""
serviceKey := key
Function compareStageFields
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
func compareStageFields(sName string, stage, work map[string]string) (allMatch bool, comparisons map[string]stageComparison) {
comparisons = make(map[string]stageComparison)
allMatch = true
// check for deleted Notes
if stgFiles.StageAttributes[sName]["deleted"] == "true" {