SUSE/saptune

View on GitHub

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)
Severity: Major
Found in system/csp.go - About 2 hrs to fix

    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
        }
    Severity: Minor
    Found in system/rpm.go - About 2 hrs 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 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 := ""
    Severity: Minor
    Found in actions/serviceacts.go - About 1 hr to fix

      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)
          }
      Severity: Minor
      Found in main.go - About 1 hr to fix

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

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

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

              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"]
              Severity: Minor
              Found in actions/stagingacts.go - About 1 hr to fix

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

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

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

                      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 := ""
                      Severity: Minor
                      Found in system/cpu.go - About 1 hr 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 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"])
                      Severity: Minor
                      Found in actions/stagingacts.go - About 1 hr 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 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"
                      Severity: Minor
                      Found in actions/stagingacts.go - About 1 hr 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

                      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") {
                      Severity: Major
                      Found in system/argsAndFlags.go and 1 other location - About 1 hr to fix
                      system/argsAndFlags.go on lines 431..447

                      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

                      Further Reading

                      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
                      Severity: Major
                      Found in system/argsAndFlags.go and 1 other location - About 1 hr to fix
                      system/argsAndFlags.go on lines 349..363

                      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

                      Further Reading

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

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

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

                            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" {
                            Severity: Minor
                            Found in actions/stagingacts.go - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language