Showing 58 of 59 total issues

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

func (a *StoredAnalyzer) updateProgress() {
    for {
        select {
        case <-a.progressDoneChan:
            return
Severity: Major
Found in pkg/analyze/stored.go and 2 other locations - About 1 hr to fix
pkg/analyze/parallel.go on lines 187..203
pkg/analyze/sequential.go on lines 163..179

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 UI.sortItems has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

func (ui *UI) sortItems() {
    if ui.sortBy == sizeSortKey {
        if ui.ShowApparentSize {
            if ui.sortOrder == descOrder {
                sort.Sort(sort.Reverse(fs.ByApparentSize(ui.currentDir.GetFiles())))
Severity: Minor
Found in tui/sort.go - About 55 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

Method UI.showFile has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
Open

func (ui *UI) showFile() *tview.TextView {
    if ui.currentDir == nil {
        return nil
    }

Severity: Minor
Found in tui/actions.go - About 55 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

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

    for _, entry := range f.GetFiles() {
        count, size, usage := entry.GetItemStats(linkedItems)
        totalSize += size
        totalUsage += usage
        itemCount += count
Severity: Minor
Found in pkg/analyze/file.go and 1 other location - About 55 mins to fix
pkg/analyze/stored.go on lines 334..350

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

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

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

    for _, entry := range f.GetFiles() {
        count, size, usage := entry.GetItemStats(linkedItems)
        totalSize += size
        totalUsage += usage
        itemCount += count
Severity: Minor
Found in pkg/analyze/stored.go and 1 other location - About 55 mins to fix
pkg/analyze/file.go on lines 210..226

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

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 strings.HasPrefix(mount.Name, "/dev") || mount.Fstype == "zfs" {
            info := &unix.Statvfs_t{}
            err := unix.Statvfs(mount.MountPoint, info)
            if err != nil && !ignoreErrors {
                return nil, err
Severity: Minor
Found in pkg/device/dev_netbsd.go and 1 other location - About 50 mins to fix
pkg/device/dev_linux.go on lines 82..96

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

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 strings.HasPrefix(mount.Name, "/dev") ||
            mount.Fstype == "zfs" ||
            mount.Fstype == "nfs" ||
            mount.Fstype == "nfs4" {
            info := &unix.Statfs_t{}
Severity: Minor
Found in pkg/device/dev_linux.go and 1 other location - About 50 mins to fix
pkg/device/dev_netbsd.go on lines 16..27

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

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 (f Files) Less(i, j int) bool {
    if f[i].GetUsage() != f[j].GetUsage() {
        return f[i].GetUsage() < f[j].GetUsage()
    }
    // if usage is the same, sort by name
Severity: Major
Found in pkg/fs/file.go and 2 other locations - About 50 mins to fix
pkg/fs/file.go on lines 94..100
pkg/fs/file.go on lines 107..113

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

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 (f ByApparentSize) Less(i, j int) bool {
    if f[i].GetSize() != f[j].GetSize() {
        return f[i].GetSize() < f[j].GetSize()
    }
    // if size is the same, sort by name
Severity: Major
Found in pkg/fs/file.go and 2 other locations - About 50 mins to fix
pkg/fs/file.go on lines 81..87
pkg/fs/file.go on lines 107..113

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

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 (f ByItemCount) Less(i, j int) bool {
    if f[i].GetItemCount() != f[j].GetItemCount() {
        return f[i].GetItemCount() < f[j].GetItemCount()
    }
    // if item count is the same, sort by name
Severity: Major
Found in pkg/fs/file.go and 2 other locations - About 50 mins to fix
pkg/fs/file.go on lines 81..87
pkg/fs/file.go on lines 94..100

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

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 SequentialAnalyzer.processDir has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
Open

func (a *SequentialAnalyzer) processDir(path string) *Dir {
    var (
        file      *File
        err       error
        totalSize int64
Severity: Minor
Found in pkg/analyze/sequential.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

Method Dir.EncodeJSON has 7 return statements (exceeds 4 allowed).
Open

func (f *Dir) EncodeJSON(writer io.Writer, topLevel bool) error {
    buff := make([]byte, 0, 20)

    buff = append(buff, []byte(`[{"name":`)...)

Severity: Major
Found in pkg/analyze/encode.go - About 45 mins to fix

    Function CreateExportUI has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        output io.Writer,
        exportOutput io.Writer,
        useColors bool,
        showProgress bool,
        constGC bool,
    Severity: Minor
    Found in report/export.go - About 45 mins to fix

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

      func ReadAnalysis(input io.Reader) (*analyze.Dir, error) {
          var data interface{}
      
          var buff bytes.Buffer
          if _, err := buff.ReadFrom(input); err != nil {
      Severity: Major
      Found in report/import.go - About 40 mins to fix

        Method UI.exportDir has 5 return statements (exceeds 4 allowed).
        Open

        func (ui *UI) exportDir(dir fs.Item, waitWritten *sync.WaitGroup) error {
            sort.Sort(sort.Reverse(dir.GetFiles()))
        
            var (
                buff bytes.Buffer
        Severity: Major
        Found in report/export.go - About 35 mins to fix

          Method LinuxDevicesInfoGetter.GetMounts has 5 return statements (exceeds 4 allowed).
          Open

          func (t LinuxDevicesInfoGetter) GetMounts() (Devices, error) {
              file, err := os.Open(t.MountsPath)
              if err != nil {
                  return nil, err
              }
          Severity: Major
          Found in pkg/device/dev_linux.go - About 35 mins to fix

            Method UI.deleteSelected has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
            Open

            func (ui *UI) deleteSelected(shouldEmpty bool) {
                row, column := ui.table.GetSelection()
                selectedItem := ui.table.GetCell(row, column).GetReference().(fs.Item)
            
                if ui.deleteInBackground {
            Severity: Minor
            Found in tui/actions.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

            Method UI.onMouse has 5 return statements (exceeds 4 allowed).
            Open

            func (ui *UI) onMouse(event *tcell.EventMouse, action tview.MouseAction) (*tcell.EventMouse, tview.MouseAction) {
                if event == nil {
                    return nil, action
                }
            
            
            Severity: Major
            Found in tui/mouse.go - About 35 mins to fix
              Severity
              Category
              Status
              Source
              Language