nesquena/gitdocs

View on GitHub

Showing 676 of 676 total issues

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

Block has too many lines. [30/25]
Open

  describe 'get /' do
    describe 'with one share' do
      before do
        Gitdocs::Share.stubs(:all).returns([:one])
        Gitdocs::Share.stubs(:first).returns(stub(id: :id))
Severity: Minor
Found in test/unit/browser_app_test.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Block has too many lines. [30/25]
Open

    describe 'on a ' do
      let(:commit) { stub(author: { name: :name, time: :time }) }
      before do
        write(File.join(%w(directory0 file0)), '')
        write(File.join(%w(directory file1)), 'foo')
Severity: Minor
Found in test/unit/repository_path_test.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Block has too many lines. [30/25]
Open

  describe 'revisions' do
    before do
      within('table#fileListing') { within('tbody') { click_link('file1') } }
      click_link('Revisions')
    end
Severity: Minor
Found in test/integration/web/browse_test.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Block has too many lines. [29/25]
Open

  describe 'get /' do
    before do
      Gitdocs::Configuration
        .stubs(:web_frontend_port)
        .returns(1111)
Severity: Minor
Found in test/unit/settings_app_test.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

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

        describe 'side effects' do
          before { subject }
          it { GitInspector.file_exist?(:local, 'directory/.gitignore').must_equal true }
          it { GitInspector.commit_count(:local).must_equal 1 }
          it { GitInspector.last_message(:local).must_equal "Auto-commit from gitdocs\n" }
Severity: Minor
Found in test/unit/repository_committer_test.rb and 1 other location - About 35 mins to fix
test/unit/repository_committer_test.rb on lines 80..85

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

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

        describe 'side effects' do
          before { subject }
          it { GitInspector.file_exist?(:local, 'directory/.gitignore').must_equal true }
          it { GitInspector.commit_count(:local).must_equal 3 }
          it { GitInspector.last_message(:local).must_equal "Auto-commit from gitdocs\n" }
Severity: Minor
Found in test/unit/repository_committer_test.rb and 1 other location - About 35 mins to fix
test/unit/repository_committer_test.rb on lines 51..56

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

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

    def file_content_render(pathname)
      return unless pathname

      tilt = Tilt.new(
        pathname,
Severity: Minor
Found in lib/gitdocs/rendering_helper.rb - 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

Block has too many lines. [28/25]
Open

  describe 'private-ish instance methods' do
    let(:notifier)  { Gitdocs::Notifier.send(:new) }
    let(:notiffany) { mock }

    describe '#notify' do
Severity: Minor
Found in test/unit/notifier_test.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Method for_merge has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def for_merge(result)
      return if result.nil?
      return if result == :no_remote
      return if result == :ok
      return if result == {}
Severity: Minor
Found in lib/gitdocs/git_notifier.rb - 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

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

      describe 'directory' do
        before do
          repository_path.expects(:join).with('new')
          repository_path.expects(:mkdir)

Severity: Minor
Found in test/unit/browser_app_test.rb and 1 other location - About 35 mins to fix
test/unit/browser_app_test.rb on lines 275..284

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

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

    def start
      unless stopped?
        say 'Gitdocs is already running, please use restart', :red
        return
      end
Severity: Minor
Found in lib/gitdocs/cli.rb - 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 fetch has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def fetch
      return nil unless valid?
      return :no_remote unless remote?

      @rugged.remotes.each { |x| @grit.remote_fetch(x.name) }
Severity: Minor
Found in lib/gitdocs/repository.rb - 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 update_all has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def self.update_all(updated_shares)
      updated_shares.each do |index, share_config|
        # Skip the share update if there is no path specified.
        next unless share_config['path'] && !share_config['path'].empty?

Severity: Minor
Found in lib/gitdocs/share.rb - 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

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

      describe 'empty file' do
        before do
          repository_path.expects(:join).with('new')
          repository_path.expects(:touch)

Severity: Minor
Found in test/unit/browser_app_test.rb and 1 other location - About 35 mins to fix
test/unit/browser_app_test.rb on lines 288..297

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

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

Block has too many lines. [28/25]
Open

describe 'fully synchronizing repositories' do
  before do
    gitdocs_create_from_remote('clone1', 'clone2', 'clone3')
    gitdocs_start
  end

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

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

      describe 'file size 0' do
        let(:relative_path) { File.join(%w(directory0 file0)) }
        it { subject[:author].must_equal :name }
        it { subject[:size].must_equal(-1) }
        it { subject[:modified].must_equal :time }
Severity: Minor
Found in test/unit/repository_path_test.rb and 1 other location - About 30 mins to fix
test/unit/repository_path_test.rb on lines 199..203

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

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

      describe 'file non-zero size' do
        let(:relative_path) { File.join(%w(directory file1)) }
        it { subject[:author].must_equal :name }
        it { subject[:size].must_equal(3) }
        it { subject[:modified].must_equal :time }
Severity: Minor
Found in test/unit/repository_path_test.rb and 1 other location - About 30 mins to fix
test/unit/repository_path_test.rb on lines 192..196

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

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

Block has too many lines. [27/25]
Open

    describe 'remote exists with no commits' do
      before { clone_remote }

      describe 'and no local commits' do
        it { subject.must_equal :nothing }
Severity: Minor
Found in test/unit/repository_test.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Avoid too many return statements within this function.
Open

      if (distance_in_minutes < 1051199) { return 'about 1 year ago'; }
Severity: Major
Found in lib/gitdocs/public/js/util.js - About 30 mins to fix
    Severity
    Category
    Status
    Source
    Language