Showing 65 of 66 total issues

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

func (ui *UI) formatWithBinPrefix(size int64) string {
    fsize := float64(size)
    asize := math.Abs(fsize)

    switch {
Severity: Major
Found in report/export.go and 3 other locations - About 4 hrs to fix
report/export.go on lines 245..265
stdout/stdout.go on lines 387..407
stdout/stdout.go on lines 409..429

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

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

func (ui *UI) formatWithDecPrefix(size int64) string {
    fsize := float64(size)
    asize := math.Abs(fsize)

    switch {
Severity: Major
Found in stdout/stdout.go and 3 other locations - About 4 hrs to fix
report/export.go on lines 223..243
report/export.go on lines 245..265
stdout/stdout.go on lines 387..407

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

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

func (ui *UI) formatWithDecPrefix(size int64) string {
    fsize := float64(size)
    asize := math.Abs(fsize)

    switch {
Severity: Major
Found in report/export.go and 3 other locations - About 4 hrs to fix
report/export.go on lines 223..243
stdout/stdout.go on lines 387..407
stdout/stdout.go on lines 409..429

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

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

func (ui *UI) formatWithBinPrefix(size int64) string {
    fsize := float64(size)
    asize := math.Abs(fsize)

    switch {
Severity: Major
Found in stdout/stdout.go and 3 other locations - About 4 hrs to fix
report/export.go on lines 223..243
report/export.go on lines 245..265
stdout/stdout.go on lines 409..429

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

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

//go:build darwin || netbsd || freebsd
// +build darwin netbsd freebsd

package analyze

Severity: Major
Found in pkg/analyze/dir_unix.go and 1 other location - About 3 hrs to fix
pkg/analyze/dir_linux-openbsd.go on lines 1..33

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

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

//go:build linux || openbsd
// +build linux openbsd

package analyze

Severity: Major
Found in pkg/analyze/dir_linux-openbsd.go and 1 other location - About 3 hrs to fix
pkg/analyze/dir_unix.go on lines 1..33

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

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

func (a *App) createUI() (UI, error) {
    var ui UI

    if a.Flags.OutputFile != "" {
        var output io.Writer
Severity: Minor
Found in cmd/gdu/app/app.go - About 3 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

Method App.createUI has 103 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (a *App) createUI() (UI, error) {
    var ui UI

    if a.Flags.OutputFile != "" {
        var output io.Writer
Severity: Major
Found in cmd/gdu/app/app.go - About 3 hrs to fix

    Method UI.showDir has 100 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (ui *UI) showDir() {
        var (
            totalUsage int64
            totalSize  int64
            maxUsage   int64
    Severity: Major
    Found in tui/show.go - About 3 hrs to fix

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

      func readMountOutput(rdr io.Reader) (Devices, error) {
          mounts := Devices{}
      
          scanner := bufio.NewScanner(rdr)
          for scanner.Scan() {
      Severity: Major
      Found in pkg/device/dev_freebsd_darwin_other.go and 1 other location - About 2 hrs to fix
      pkg/device/dev_bsd.go on lines 46..75

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

      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 readMountOutput(rdr io.Reader) (Devices, error) {
          mounts := Devices{}
      
          scanner := bufio.NewScanner(rdr)
          for scanner.Scan() {
      Severity: Major
      Found in pkg/device/dev_bsd.go and 1 other location - About 2 hrs to fix
      pkg/device/dev_freebsd_darwin_other.go on lines 48..77

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

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

      func (ui *UI) deleteMarked(shouldEmpty bool) {
          var action, acting string
          if shouldEmpty {
              action = "empty "
              acting = "emptying"
      Severity: Minor
      Found in tui/marked.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 CreateUI has 82 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func CreateUI(
          app common.TermApplication,
          screen tcell.Screen,
          output io.Writer,
          useColors bool,
      Severity: Major
      Found in tui/tui.go - About 2 hrs to fix

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

                if f.IsDir() {
                    if a.ignoreDir(name, entryPath) {
                        continue
                    }
                    dirCount++
        Severity: Major
        Found in pkg/analyze/parallel.go and 1 other location - About 2 hrs to fix
        pkg/analyze/sequential.go on lines 113..149

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

        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

                if f.IsDir() {
                    if a.ignoreDir(name, entryPath) {
                        continue
                    }
                    dirCount++
        Severity: Major
        Found in pkg/analyze/sequential.go and 1 other location - About 2 hrs to fix
        pkg/analyze/parallel.go on lines 121..162

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

        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 processMounts(mounts Devices, ignoreErrors bool) (Devices, error) {
            devices := Devices{}
        
            for _, mount := range mounts {
                if strings.HasPrefix(mount.Name, "/dev") || mount.Fstype == "zfs" {
        Severity: Major
        Found in pkg/device/dev_netbsd.go and 1 other location - About 2 hrs to fix
        pkg/device/dev_freebsd_darwin_other.go on lines 79..98

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

        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 processMounts(mounts Devices, ignoreErrors bool) (Devices, error) {
            devices := Devices{}
        
            for _, mount := range mounts {
                if strings.HasPrefix(mount.Name, "/dev") || mount.Fstype == "zfs" {
        Severity: Major
        Found in pkg/device/dev_freebsd_darwin_other.go and 1 other location - About 2 hrs to fix
        pkg/device/dev_netbsd.go on lines 12..31

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

        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

        ParentDir has 21 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type ParentDir struct {
            Path string
        }
        Severity: Minor
        Found in pkg/analyze/stored.go - About 2 hrs to fix

          File has 21 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type File struct {
              Mtime  time.Time
              Parent fs.Item
              Name   string
              Size   int64
          Severity: Minor
          Found in pkg/analyze/file.go - About 2 hrs to fix

            Method StoredAnalyzer.processDir has 77 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (a *StoredAnalyzer) processDir(path string) *StoredDir {
                var (
                    file      *File
                    err       error
                    totalSize int64
            Severity: Major
            Found in pkg/analyze/stored.go - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language