SUSE/saptune

View on GitHub

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
Severity: Major
Found in app/app.go - About 55 mins to fix

    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
        }
    Severity: Major
    Found in system/cpu.go - About 45 mins to fix

      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
      Severity: Minor
      Found in sap/note/ini.go - About 45 mins to fix

      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]
                                      }
      Severity: Major
      Found in system/cpu.go - About 45 mins to fix

        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,
        Severity: Major
        Found in sap/note/sectLogin.go - About 45 mins to fix

          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{}
          Severity: Minor
          Found in system/fs.go - About 45 mins to fix

          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")
          Severity: Minor
          Found in actions/solutionacts.go - About 45 mins to fix

          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")) {
          Severity: Major
          Found in system/argsAndFlags.go - About 40 mins to fix

            Function CmpRpmVers has 6 return statements (exceeds 4 allowed).
            Open

            func CmpRpmVers(vers1, vers2 string) bool {
                if vers1 == "" {
                    // package not installed
                    return false
                }
            Severity: Major
            Found in system/rpm.go - About 40 mins to fix

              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) {
              Severity: Minor
              Found in actions/table.go - About 35 mins to fix

                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) {
                Severity: Minor
                Found in actions/table.go - About 35 mins to fix

                  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
                  Severity: Major
                  Found in system/cpu.go - About 35 mins to fix

                    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
                    Severity: Minor
                    Found in txtparser/misc.go - About 35 mins to fix

                    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):
                    Severity: Major
                    Found in sap/note/sectBlock.go - About 35 mins to fix

                      Function GetBlkVal has 5 return statements (exceeds 4 allowed).
                      Open

                      func GetBlkVal(key string, cur *param.BlockDeviceQueue) (string, string, error) {
                          retVal := ""
                          info := ""
                      
                          switch {
                      Severity: Major
                      Found in sap/note/sectBlock.go - About 35 mins to fix

                        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
                        Severity: Major
                        Found in app/app.go - About 35 mins to fix

                          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
                              }
                          Severity: Major
                          Found in app/app.go - About 35 mins to fix

                            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
                                }
                            Severity: Major
                            Found in app/app.go - About 35 mins to fix

                              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
                              Severity: Major
                              Found in app/app.go - About 35 mins to fix

                                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
                                
                                
                                Severity: Minor
                                Found in sap/note/ini.go - About 25 mins to fix

                                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

                                Severity
                                Category
                                Status
                                Source
                                Language