Showing 64 of 74 total issues
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
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
Avoid deeply nested control flow statements. Open
if FLFields[0] == cpuName && FLFields[1] == stateName {
oldState = FLFields[2]
}
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,
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 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
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 printTableFooter
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func printTableFooter(writer io.Writer, header string, footnote []string, reminder map[string]string, noteReminder *[]system.JPNotesRemind) {
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 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 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):
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.RevertNote
has 5 return statements (exceeds 4 allowed). Open
func (app *App) RevertNote(noteID string, permanent bool) error {
noteTemplate, err := app.GetNoteByID(noteID)
if err != nil {
// to revert an applied note even if the corresponding
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
}
Method App.VerifyNote
has 5 return statements (exceeds 4 allowed). Open
func (app *App) VerifyNote(noteID string) (conforming bool, comparisons map[string]note.FieldComparison, valApplyList []string, err error) {
theNote, err := app.GetNoteByID(noteID)
if err != nil {
return
}
Method App.TuneSolution
has 5 return statements (exceeds 4 allowed). Open
func (app *App) TuneSolution(solName string) (removedExplicitNotes []string, err error) {
removedExplicitNotes = make([]string, 0)
sol, err := app.GetSolutionByName(solName)
if err != nil {
return
Method INISettings.Optimise
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func (vend INISettings) Optimise() (Note, error) {
blckOK := make(map[string][]string)
scheds := ""
next := false
- 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"