hardpixel/marv

View on GitHub

Showing 17 of 17 total issues

Class Global has 38 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Global

    attr_accessor :config, :path, :servers, :plugins, :themes, :layouts

    def initialize(task, from_command=false)
Severity: Minor
Found in lib/marv/global.rb - About 5 hrs to fix

    Class Server has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Server
    
          attr_accessor :task, :name, :path, :config, :host, :port, :database, :context
    
          # Initialize server config
    Severity: Minor
    Found in lib/marv/server/server.rb - About 3 hrs to fix

      File global.rb has 254 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Marv
        class Global
      
          attr_accessor :config, :path, :servers, :plugins, :themes, :layouts
      
      
      Severity: Minor
      Found in lib/marv/global.rb - About 2 hrs to fix

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

              def ask_database_details
                options = {}
                options[:db_user] = @task.ask_input "MySQL database username:", :default => @global.config[:db_user]
                options[:db_password] = @task.ask_input "MySQL database password:", :default => @global.config[:db_password]
                options[:db_host] = @task.ask_input "MySQL database host:", :default => @global.config[:db_host]
        Severity: Major
        Found in lib/marv/server/server.rb and 1 other location - About 1 hr to fix
        lib/marv/project/create.rb on lines 48..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 54.

        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

              def ask_author_details
                options = {}
        
                options[:author] = @task.ask_input "Enter project author:", :default => @global.config[:author]
                options[:author_uri] = @task.ask_input "Enter project author URI:", :default => @global.config[:author_uri]
        Severity: Major
        Found in lib/marv/project/create.rb and 1 other location - About 1 hr to fix
        lib/marv/server/server.rb on lines 127..134

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

        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 init_sprockets has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def init_sprockets
                if ExecJS::Runtimes.runtimes.none?(&:available?)
                  @task.say_error "No execjs runtime found! Aborting..."
                  abort
                end
        Severity: Minor
        Found in lib/marv/project/builder/assets.rb - About 1 hr to fix

          Method project_contents has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def self.project_contents
                  assets_path = @project.assets_path.gsub(/#{@project.root}\//, '')
                  source_path = @project.source_path.gsub(/#{@project.root}\//, '')
                  config_file = @project.config_file.gsub(/#{@project.root}\//, '')
          
          
          Severity: Minor
          Found in lib/marv/project/guard.rb - About 1 hr to fix

            Method list has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def list(dir='all')
                    servers = Marv::Global.new(self).servers
            
                    if dir == 'all'
                      say_info "Available marv servers:", true
            Severity: Minor
            Found in lib/marv/cli/server.rb - About 1 hr to fix

              Method list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def list(dir='all')
                      servers = Marv::Global.new(self).servers
              
                      if dir == 'all'
                        say_info "Available marv servers:", true
              Severity: Minor
              Found in lib/marv/cli/server.rb - 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 create_project_dirs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def create_project_dirs
                      ::Dir.glob(::File.join(@layout, '**', '*')).each do |dir|
                        if ::File.directory?(dir)
                          # Get source and target files
                          source_dir = dir.gsub(@layout, '')
              Severity: Minor
              Found in lib/marv/project/create.rb - 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 init_sprockets has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                    def init_sprockets
                      if ExecJS::Runtimes.runtimes.none?(&:available?)
                        @task.say_error "No execjs runtime found! Aborting..."
                        abort
                      end
              Severity: Minor
              Found in lib/marv/project/builder/assets.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 link_target has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def link_target
                      target = link_to_server unless link_to_server.nil?
                      target = link_to_folder unless link_to_folder.nil?
                      target = link_global unless link_global.nil?
              
              
              Severity: Minor
              Found in lib/marv/project/actions.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 stop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def stop(message=true)
                      abort_noexist
                      pid_file = ::File.join(@path, 'php.pid')
              
                      begin
              Severity: Minor
              Found in lib/marv/server/actions.rb - About 25 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 build_asset_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def build_asset_file(asset)
                      destination = ::File.join(@project.build_path, asset)
              
                      @task.shell.mute do
                        sprocket = @sprockets.find_asset(asset.last)
              Severity: Minor
              Found in lib/marv/project/builder/assets.rb - About 25 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 generate_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def generate_config(from_command=false)
                    if from_command
                      ::File.exists?(config_file) ? reconfigure : configure(from_command)
                    else
                      configure unless ::File.exists?(config_file)
              Severity: Minor
              Found in lib/marv/global.rb - About 25 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 _prompt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def _prompt(ending_char)
                      proc do |target_self, nest_level, pry|
                        history    = pry.input_ring.size
                        process    = ::Guard.listener.paused? ? _colorize("pause", :yellow) : _colorize("marv", :green)
                        level      = ":#{nest_level}" unless nest_level.zero?
              Severity: Minor
              Found in lib/marv/project/guard/pry.rb - About 25 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 stop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def stop(dir)
                      unless dir == 'all'
                        server = Marv::Server::Server.new(self, dir)
                        action = Marv::Server::Actions.new(server)
                        action.stop
              Severity: Minor
              Found in lib/marv/cli/server.rb - About 25 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