nesquena/gitdocs

View on GitHub
lib/gitdocs/repository/path.rb

Summary

Maintainability
A
45 mins
Test Coverage

Class has too many lines. [110/100]
Open

    class Path
      attr_reader :relative_path

      # @param [Gitdocs::Repository] repository
      # @param [String] relative_path
Severity: Minor
Found in lib/gitdocs/repository/path.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method total_size has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def total_size
        result =
          if File.directory?(@absolute_path)
            Dir[File.join(@absolute_path, '**', '*')].reduce(0) do |size, filename|
              File.symlink?(filename) ? size : size + File.size(filename)
Severity: Minor
Found in lib/gitdocs/repository/path.rb - 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

Line is too long. [83/80]
Open

            Dir[File.join(@absolute_path, '**', '*')].reduce(0) do |size, filename|
Severity: Minor
Found in lib/gitdocs/repository/path.rb by rubocop

Use result.zero? instead of result == 0.
Open

        return -1 if result == 0
Severity: Minor
Found in lib/gitdocs/repository/path.rb by rubocop

This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

Example: EnforcedStyle: predicate (default)

# bad

foo == 0
0 > foo
bar.baz > 0

# good

foo.zero?
foo.negative?
bar.baz.positive?

Example: EnforcedStyle: comparison

# bad

foo.zero?
foo.negative?
bar.baz.positive?

# good

foo == 0
0 > foo
bar.baz > 0

Unnecessary utf-8 encoding comment.
Open

# -*- encoding : utf-8 -*-
Severity: Minor
Found in lib/gitdocs/repository/path.rb by rubocop

There are no issues that match your filters.

Category
Status