SUSE/saptune

View on GitHub

Showing 74 of 74 total issues

File stagingacts.go has 796 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package actions

import (
    "fmt"
    "github.com/SUSE/saptune/app"
Severity: Major
Found in actions/stagingacts.go - About 1 day to fix

    Function SetForceLatency has a Cognitive Complexity of 62 (exceeds 20 allowed). Consider refactoring.
    Open

    func SetForceLatency(value, savedStates string, revert bool) error {
        oldState := ""
    
        if !supportsForceLatencySettings(value) {
            return nil
    Severity: Minor
    Found in system/cpu.go - About 7 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

    File serviceacts.go has 709 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package actions
    
    import (
        "bytes"
        "fmt"
    Severity: Minor
    Found in actions/serviceacts.go - About 7 hrs to fix

      Function stagingActionRelease has a Cognitive Complexity of 57 (exceeds 20 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 6 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 ParseINI has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
      Open

      func ParseINI(input string) *INIFile {
          ret := &INIFile{
              AllValues: make([]INIEntry, 0, 64),
              KeyValue:  make(map[string]map[string]INIEntry),
          }
      Severity: Minor
      Found in txtparser/ini.go - About 4 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 ParseINI has 94 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func ParseINI(input string) *INIFile {
          ret := &INIFile{
              AllValues: make([]INIEntry, 0, 64),
              KeyValue:  make(map[string]map[string]INIEntry),
          }
      Severity: Major
      Found in txtparser/ini.go - About 2 hrs to fix

        Function CompareNoteFields has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
        Open

        func CompareNoteFields(actualNote, expectedNote Note) (allMatch bool, comparisons map[string]FieldComparison, valApplyList []string) {
            comparisons = make(map[string]FieldComparison)
            allMatch = true
            grubAvail := false
            // Compare all fields
        Severity: Minor
        Found in sap/note/note.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

        File app.go has 530 lines of code (exceeds 500 allowed). Consider refactoring.
        Open

        package app
        
        import (
            "fmt"
            "github.com/SUSE/saptune/sap"
        Severity: Minor
        Found in app/app.go - About 2 hrs to fix

          App has 24 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type App struct {
              SysconfigPrefix  string
              AllNotes         map[string]note.Note         // all notes
              AllSolutions     map[string]solution.Solution // all solutions
              TuneForSolutions []string                     // list of solution names to tune, must always be sorted in ascending order.
          Severity: Minor
          Found in app/app.go - About 2 hrs to fix

            Function SetLoginVal has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
            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: Minor
            Found in sap/note/sectLogin.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 OptServiceVal has a Cognitive Complexity of 33 (exceeds 20 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 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

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

            func (rakb BlockDeviceReadAheadKB) Inspect() (Parameter, error) {
                if len(rakb.ReadAheadKB) != 0 {
                    // inspect needs to run only once per saptune call
                    return rakb, nil
                }
            Severity: Major
            Found in sap/param/io.go and 2 other locations - About 2 hrs to fix
            sap/param/io.go on lines 97..116
            sap/param/io.go on lines 237..256

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

            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 3 locations. Consider refactoring.
            Open

            func (mskb BlockDeviceMaxSectorsKB) Inspect() (Parameter, error) {
                if len(mskb.MaxSectorsKB) != 0 {
                    // inspect needs to run only once per saptune call
                    return mskb, nil
                }
            Severity: Major
            Found in sap/param/io.go and 2 other locations - About 2 hrs to fix
            sap/param/io.go on lines 97..116
            sap/param/io.go on lines 167..186

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

            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 3 locations. Consider refactoring.
            Open

            func (ior BlockDeviceNrRequests) Inspect() (Parameter, error) {
                if len(ior.NrRequests) != 0 {
                    // inspect needs to run only once per saptune call
                    return ior, nil
                }
            Severity: Major
            Found in sap/param/io.go and 2 other locations - About 2 hrs to fix
            sap/param/io.go on lines 167..186
            sap/param/io.go on lines 237..256

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

            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

            File solutionacts.go has 513 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            package actions
            
            import (
                "bufio"
                "bytes"
            Severity: Minor
            Found in actions/solutionacts.go - About 2 hrs to fix

              Method INISettings.Optimise has 82 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (vend INISettings) Optimise() (Note, error) {
                  blckOK := make(map[string][]string)
                  scheds := ""
                  next := false
              
              
              Severity: Major
              Found in sap/note/ini.go - About 2 hrs to fix

                Function printNoteAndSols has 80 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: Major
                Found in actions/serviceacts.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 main has 75 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 2 hrs 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
                      Severity
                      Category
                      Status
                      Source
                      Language