SUSE/saptune

View on GitHub

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 := ""
Severity: Minor
Found in system/cpu.go - About 1 hr to fix

    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
        }
    Severity: Minor
    Found in sap/note/sectBlock.go - About 1 hr to fix

      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
      Severity: Minor
      Found in system/argsAndFlags.go - About 1 hr to fix

        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 {
        Severity: Minor
        Found in sap/note/note.go - About 1 hr to fix

          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

            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

              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

                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

                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

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

                    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 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 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.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

                              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 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
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language