nesquena/gitdocs

View on GitHub

Showing 31 of 676 total issues

File repository_test.rb has 608 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require File.expand_path('../test_helper', __FILE__)

describe Gitdocs::Repository do
  before do
    FileUtils.rm_rf(GitFactory.working_directory)
Severity: Major
Found in test/unit/repository_test.rb - About 1 day to fix

    File repository_path_test.rb has 314 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require File.expand_path('../test_helper', __FILE__)
    
    describe Gitdocs::Repository::Path do
      let(:path) { Gitdocs::Repository::Path.new(repository, "/#{relative_path}") }
      let(:repository) { stub(root: GitFactory.expand_path(:local)) }
    Severity: Minor
    Found in test/unit/repository_path_test.rb - About 3 hrs to fix

      Class Repository has 28 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Repository
          attr_reader :invalid_reason
      
          class InvalidError < StandardError; end
          class FetchError < StandardError; end
      Severity: Minor
      Found in lib/gitdocs/repository.rb - About 3 hrs to fix

        File browser_app_test.rb has 301 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        ENV['RACK_ENV'] = 'test'
        require File.expand_path('../test_helper', __FILE__)
        require 'rack/test'
        
        describe Gitdocs::BrowserApp do
        Severity: Minor
        Found in test/unit/browser_app_test.rb - About 3 hrs to fix

          Method merge has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def merge
                return nil        unless valid?
                return :no_remote unless remote?
                return :ok        unless remote_oid
                return :ok        if remote_oid == current_oid
          Severity: Minor
          Found in lib/gitdocs/repository.rb - 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

          Method start has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def start
                Celluloid.boot unless Celluloid.running?
                @supervisor = Celluloid::SupervisionGroup.run!
          
                # Start the web server ###################################################
          Severity: Minor
          Found in lib/gitdocs/celluloid_facade.rb - About 1 hr to fix

            Method push has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def push
                  return            unless valid?
                  return :no_remote unless remote?
                  return :nothing   unless current_oid
                  return :nothing   if remote_oid == current_oid
            Severity: Minor
            Found in lib/gitdocs/repository.rb - 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 humanize has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              humanize : function(str, shortened) {
                var parts = str.split('T')[0].split('-');
                var humDate = new Date();
            
                humDate.setFullYear(Number(parts[0]));
            Severity: Minor
            Found in lib/gitdocs/public/js/util.js - About 1 hr to fix

              Method after_teardown has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def after_teardown
                  restore_env
                  processes.clear
              
                  if File.exist?(PID_FILE)
              Severity: Minor
              Found in test/integration/test_helper.rb - About 1 hr to fix

                Function humanizeBytes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  humanizeBytes : function(filesize) {
                    if (filesize === null || filesize <= 0 || filesize === "") { return "&mdash;"; }
                    if (filesize >= 1073741824) {
                         filesize = Utils.number_format(filesize / 1073741824, 2, '.', '') + ' Gb';
                    } else {
                Severity: Minor
                Found in lib/gitdocs/public/js/util.js - 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

                Method after_teardown has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  def after_teardown
                    restore_env
                    processes.clear
                
                    if File.exist?(PID_FILE)
                Severity: Minor
                Found in test/integration/test_helper.rb - 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

                Method start has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def start(host, port)
                      Gitdocs.log_info("Starting Gitdocs v#{VERSION}...")
                      Gitdocs.log_info(
                        "Using configuration root: '#{Initializer.root_dirname}'"
                      )
                Severity: Minor
                Found in lib/gitdocs/manager.rb - About 1 hr to fix

                  Function distance_of_time_in_words has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    distance_of_time_in_words: function(to, from) {
                        var distance_in_seconds = ((to - from) / 1000);
                        var distance_in_minutes = Math.floor(distance_in_seconds / 60);
                  
                        if (distance_in_minutes <= 0) { return 'less than a minute ago'; }
                  Severity: Minor
                  Found in lib/gitdocs/public/js/util.js - 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 number_format has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    number_format : function( number, decimals, dec_point, thousands_sep ) {
                        var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
                        var d = dec_point === undefined ? "," : dec_point;
                        var t = thousands_sep === undefined ? "." : thousands_sep, s = n < 0 ? "-" : "";
                        var i = parseInt(n = Math.abs(+n || 0).toFixed(c), 10) + "", j = (j = i.length) > 3 ? j % 3 : 0;
                  Severity: Minor
                  Found in lib/gitdocs/public/js/util.js - 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 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

                  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

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

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

                  Severity
                  Category
                  Status
                  Source
                  Language