SUSE/saptune

View on GitHub

Showing 96 of 96 total issues

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

func NoticeLog(txt string, stuff ...interface{}) {
    if noticeLogger != nil {
        noticeLogger.SetPrefix(logTimeFormat() + severNoticeFormat + logpidFormat)
        noticeLogger.Printf(CalledFrom()+txt+"\n", stuff...)
        jWriteMsg("NOTICE", fmt.Sprintf(CalledFrom()+txt+"\n", stuff...))
Severity: Major
Found in system/logging.go and 1 other location - About 1 hr to fix
system/logging.go on lines 65..74

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

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 WarningLog(txt string, stuff ...interface{}) {
    if warningLogger != nil {
        warningLogger.SetPrefix(logTimeFormat() + severWarnFormat + logpidFormat)
        warningLogger.Printf(CalledFrom()+txt+"\n", stuff...)
        jWriteMsg("WARNING", fmt.Sprintf(CalledFrom()+txt+"\n", stuff...))
Severity: Major
Found in system/logging.go and 1 other location - About 1 hr to fix
system/logging.go on lines 45..54

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

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

    if csp == "" {
        // BiosVersion
        if content, err := ioutil.ReadFile(dmiBiosVersion); err == nil {
            // check for AWS
            matches := isAWS.FindStringSubmatch(string(content))
Severity: Major
Found in system/csp.go and 1 other location - About 1 hr to fix
system/csp.go on lines 83..102

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

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

    if csp == "" {
        // SystemManufacturer
        if content, err := ioutil.ReadFile(dmiSystemManufacturer); err == nil {
            // check for Azure
            matches := isAzure.FindStringSubmatch(string(content))
Severity: Major
Found in system/csp.go and 1 other location - About 1 hr to fix
system/csp.go on lines 113..132

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

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 CollectBlockDeviceInfo has 55 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func CollectBlockDeviceInfo() []string {
    bdevConf := BlockDev{
        AllBlockDevs:    make([]string, 0, 64),
        BlockAttributes: make(map[string]map[string]string),
    }
Severity: Minor
Found in system/blockdev.go - About 1 hr to fix

    Function CheckRpmVers has 54 lines of code (exceeds 50 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 1 hr to fix

      Function WrapTxt has 54 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func WrapTxt(text string, width int) (folded []string) {
          var words []string
          fallback := false
      
          if strings.Contains(text, " ") {
      Severity: Minor
      Found in system/system.go - About 1 hr to fix

        Method App.TuneNote has 53 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (app *App) TuneNote(noteID string) error {
            savConf := false
            aNote, err := app.GetNoteByID(noteID)
            if err != nil {
                return err
        Severity: Minor
        Found in app/app.go - About 1 hr to fix

          Function getValidBlockDevices has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
          Open

          func getValidBlockDevices() (valDevs []string) {
              var isMpath = regexp.MustCompile(`^mpath-\w+`)
              var isLVM = regexp.MustCompile(`^LVM-\w+`)
              candidates := []string{}
              excludedevs := []string{}
          Severity: Minor
          Found in system/blockdev.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 WrapTxt has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
          Open

          func WrapTxt(text string, width int) (folded []string) {
              var words []string
              fallback := false
          
              if strings.Contains(text, " ") {
          Severity: Minor
          Found in system/system.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 readVersionSection has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
          Confirmed

          func readVersionSection(fileName string) ([]string, bool, error) {
              skipSection := false
              staging := false
              chkVersEntries := map[string]bool{"missing": false, "found": false, "isNew": false, "isOld": false, "skip": false, "mandVers": false, "mandDate": false, "mandDesc": false, "mandRefs": false}
              vsection := []string{}
          Severity: Minor
          Found in txtparser/section.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 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

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

                      if flag != "new" {
                          if stgFiles.StageAttributes[stageName]["applied"] == "true" {
                              fmt.Fprint(writer, txtNoteApplied)
                              retVal = system.MaxI(retVal, 1)
                          } else if stgFiles.StageAttributes[stageName]["enabled"] == "true" {
                  Severity: Major
                  Found in actions/stagingacts.go and 1 other location - About 1 hr to fix
                  actions/stagingacts.go on lines 334..346

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

                  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

                      if flag != "new" {
                          if stgFiles.StageAttributes[stageName]["applied"] == "true" {
                              fmt.Fprint(writer, txtSolApplied)
                              retVal = system.MaxI(retVal, 1)
                          } else if stgFiles.StageAttributes[stageName]["enabled"] == "true" {
                  Severity: Major
                  Found in actions/stagingacts.go and 1 other location - About 1 hr to fix
                  actions/stagingacts.go on lines 414..426

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

                  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 IsValidforReadAheadKB(blockdev, readahead string) bool {
                      elev, _ := system.GetSysChoice(path.Join("block", blockdev, "queue", "scheduler"))
                      if elev != "" && elev != "NA" && elev != "PNA" {
                          file := path.Join("block", blockdev, "queue", "read_ahead_kb")
                          if tstErr := system.TestSysString(file, readahead); tstErr == nil {
                  Severity: Minor
                  Found in sap/param/io.go and 1 other location - About 1 hr to fix
                  sap/param/io.go on lines 319..328

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

                  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 IsValidforNrRequests(blockdev, nrreq string) bool {
                      elev, _ := system.GetSysChoice(path.Join("block", blockdev, "queue", "scheduler"))
                      if elev != "" && elev != "NA" && elev != "PNA" {
                          file := path.Join("block", blockdev, "queue", "nr_requests")
                          if tstErr := system.TestSysString(file, nrreq); tstErr == nil {
                  Severity: Minor
                  Found in sap/param/io.go and 1 other location - About 1 hr to fix
                  sap/param/io.go on lines 334..343

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

                  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

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