Showing 68 of 96 total issues
Function GetFLInfo
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func GetFLInfo() (string, string, bool) {
lat := 0
maxlat := 0
supported := false
savedStates := ""
Function OptBlkVal
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func OptBlkVal(key, cfgval string, cur *param.BlockDeviceQueue, bOK map[string][]string) (string, string) {
info := ""
if cfgval == "" {
return cfgval, info
}
Function chkGlobalOpts
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func chkGlobalOpts(cmdLinePos map[string]int) bool {
stArgs := os.Args
ret := true
globOpt := false
globPos := 1
Function GetTuningOptions
has 51 lines of code (exceeds 50 allowed). Consider refactoring. Open
func GetTuningOptions(saptuneTuningDir, thirdPartyTuningDir string) TuningOptions {
ret := TuningOptions{}
// Collect those defined by saptune
_, files := system.ListDir(saptuneTuningDir, "saptune tuning definitions")
for _, fileName := range files {
Method App.TuneNote
has 9 return statements (exceeds 4 allowed). Open
func (app *App) TuneNote(noteID string) error {
savConf := false
aNote, err := app.GetNoteByID(noteID)
if err != nil {
return err
Function SetLoginVal
has 7 return statements (exceeds 4 allowed). Open
func SetLoginVal(key, value string, revert bool) error {
switch key {
case "UserTasksMax":
system.DebugLog("SetLoginVal - key is '%s', value is '%s', revert is '%v'\n", key, value, revert)
// because of systemd problems during shutting down a node,
Avoid deeply nested control flow statements. Open
} else if currentCPUDriver() == "none" {
WarningLog("Latency settings not supported by the system, no active cpuidle driver")
setLatency = false
}
Method INISettings.Apply
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (vend INISettings) Apply() error {
var err error
errs := make([]error, 0)
revertValues := false
pvendID := vend.ID
- 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 SolutionActionList
has a Cognitive Complexity of 23 (exceeds 20 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")
- 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
Avoid deeply nested control flow statements. Open
if FLFields[0] == cpuName && FLFields[1] == stateName {
oldState = FLFields[2]
}
Method MountPoints.GetByMountOption
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (mounts MountPoints) GetByMountOption(fstype, mountOption, chkDflt string) ([]string, []string) {
var found bool
var dflt bool
mntOK := []string{}
mntNok := []string{}
- 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 printTableFooter
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func printTableFooter(writer io.Writer, header string, footnote []string, reminder map[string]string, hasDiff bool, noteReminder *[]system.JPNotesRemind) {
Consider simplifying this complex logical expression. Open
if len(os.Args) < cmdLinePos["cmdOpt"]+1 || (!IsFlagSet("force") && !IsFlagSet("dryrun") && !IsFlagSet("colorscheme") && !IsFlagSet("show-non-compliant") && !IsFlagSet("non-compliance-check")) {
Function CmpRpmVers
has 6 return statements (exceeds 4 allowed). Open
func CmpRpmVers(vers1, vers2 string) bool {
if vers1 == "" {
// package not installed
return false
}
Function PrintNoteFields
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func PrintNoteFields(writer io.Writer, header string, noteComparisons map[string]map[string]note.FieldComparison, printComparison bool, result *system.JPNotes) {
Function CalculateOptimumValue
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func CalculateOptimumValue(operator Operator, currentValue string, expectedValue string) (string, error) {
if operator == OperatorEqual {
return expectedValue, nil
}
// Numeric comparisons
- 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 GetBlkVal
has 5 return statements (exceeds 4 allowed). Open
func GetBlkVal(key string, cur *param.BlockDeviceQueue) (string, string, error) {
retVal := ""
info := ""
switch {
Method App.RevertSolution
has 5 return statements (exceeds 4 allowed). Open
func (app *App) RevertSolution(solName string) error {
sol, err := app.GetSolutionByName(solName)
if err != nil {
return err
}
Function SecureBootEnabled
has 5 return statements (exceeds 4 allowed). Open
func SecureBootEnabled() bool {
var isSecBootFileName = regexp.MustCompile(`^SecureBoot-\w[\w-]+`)
if _, err := os.Stat(efiVarsDir); os.IsNotExist(err) {
InfoLog("no EFI directory '%+s' found, assuming legacy boot", efiVarsDir)
return false
Function SetBlkVal
has 5 return statements (exceeds 4 allowed). Open
func SetBlkVal(key, value string, cur *param.BlockDeviceQueue, revert bool) error {
var err error
switch {
case system.IsSched.MatchString(key):