sshaw/itunes_store_transporter_web

View on GitHub

Showing 23 of 23 total issues

Class TransporterJob has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

class TransporterJob < ActiveRecord::Base
  include ITunes::Store::Transporter::Web

  STATES = [:queued, :running, :success, :failure]
  STATES.each do |s|
Severity: Minor
Found in models/transporter_job.rb - About 3 hrs to fix

    Method prompt_for_config has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def prompt_for_config
      unless $config[:db_driver]
        puts "Select your database: "
        $supported_drivers.each_with_index { |dep, i| puts "#{i + 1}: #{dep.name}" }
    
    
    Severity: Minor
    Found in install.rb - 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

    Function fileBrowser has 80 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        $.fn.fileBrowser = function(o, handler) {
            if( !o ) var o = {};
            if( o.root == undefined ) o.root = '';
            if( o.script == undefined ) o.script = 'browse';
            if( o.title == undefined ) o.title = 'Select a File';
    Severity: Major
    Found in public/javascripts/jqueryFileTree.js - About 3 hrs to fix

      Method current_search_query has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

                def current_search_query(accounts)
                  terms = []
      
                  [:priority, :state, :target, :type].each do |name|
                    next if params[name].blank?
      Severity: Minor
      Found in app/helpers/jobs_helper.rb - 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

      Method find has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        def find(path, options)
          files = []
      
          Dir.foreach(path) do |name|
            next if name =~ %r|\A\.\.?|
      Severity: Minor
      Found in lib/fs_util.rb - 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

      Method install has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def install
        puts "Installing..."
      
        db_driver = $config[:db_driver] || $default_driver
        db_config = {
      Severity: Minor
      Found in install.rb - About 1 hr to fix

        Function bindTree has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                    var bindTree = function(t) {
                        $(t).find('LI A').bind('click', function() {
                            var count = ($(this).data('clickcount') || 0) + 1;
        
                            if(count == 1) {
        Severity: Minor
        Found in public/javascripts/jqueryFileTree.js - About 1 hr to fix

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

                    def current_search_query(accounts)
                      terms = []
          
                      [:priority, :state, :target, :type].each do |name|
                        next if params[name].blank?
          Severity: Minor
          Found in app/helpers/jobs_helper.rb - About 1 hr to fix

            Method install has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def install
              puts "Installing..."
            
              db_driver = $config[:db_driver] || $default_driver
              db_config = {
            Severity: Minor
            Found in install.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 sort_by has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                      def sort_by(column)
                        current_column, current_dir = params[:order].to_s.split(":")
            
                        dir  = current_dir == "asc" ? "desc" : "asc"
                        link = link_to(column.titleize, current_path(params.merge(:order => "#{column}:#{dir}")))
            Severity: Minor
            Found in app/helpers/jobs_helper.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 to_bool has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def to_bool(val)
                case val
                  when String
                val == "true" || val == "1" ? true : false
                  when Fixnum
            Severity: Minor
            Found in models/transporter_job.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

            Consider simplifying this complex logical expression.
            Open

                  if (element.data('remote') == true) {
                    e.preventDefault(); e.stopped = true;
                    JSAdapter.sendRequest(element, {
                      verb: element.data('method') || element.attr('method') || 'post',
                      url: element.attr('action'),
            Severity: Major
            Found in public/javascripts/jquery-ujs.js - About 40 mins to fix

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

                        def account_options(accounts)
                          options = []
              
                          Array(accounts).sort_by { |u| u.username }.group_by(&:username).each do |_, users|
                            users.each do |u|
              Severity: Minor
              Found in app/helpers/jobs_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 format_option_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                        def format_option_value(name, value)
                          if name == :rate && value.present?
                            number_with_delimiter(value) << " Kbps"
                          elsif name == :password
                            "*" * 8
              Severity: Minor
              Found in app/helpers/jobs_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

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

                  $('#open_file_browser_for_failure').fileBrowser({title: 'Select Failure Directory', type: 'directory'}, function(file) {
                  iTMS.fileSelected('failure', file);
                  });
              Severity: Major
              Found in public/javascripts/application.js and 3 other locations - About 30 mins to fix
              public/javascripts/application.js on lines 40..42
              public/javascripts/application.js on lines 44..46
              public/javascripts/application.js on lines 52..54

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

              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

                  $('#open_file_browser_for_package').fileBrowser({title: 'Select Your Package', type: 'directory'}, function(file) {
                  iTMS.fileSelected('package', file);
                  });
              Severity: Major
              Found in public/javascripts/application.js and 3 other locations - About 30 mins to fix
              public/javascripts/application.js on lines 44..46
              public/javascripts/application.js on lines 48..50
              public/javascripts/application.js on lines 52..54

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

              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

                  $('#open_file_browser_for_execute').fileBrowser({title: 'Select Program to Execute', type: 'file'}, function(file) {
                  iTMS.fileSelected('execute', file);
                  });
              Severity: Major
              Found in public/javascripts/application.js and 3 other locations - About 30 mins to fix
              public/javascripts/application.js on lines 40..42
              public/javascripts/application.js on lines 44..46
              public/javascripts/application.js on lines 48..50

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

              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

                  $('#open_file_browser_for_success').fileBrowser({title: 'Select Success Directory', type: 'directory'}, function(file) {
                  iTMS.fileSelected('success', file);
                  });
              Severity: Major
              Found in public/javascripts/application.js and 3 other locations - About 30 mins to fix
              public/javascripts/application.js on lines 40..42
              public/javascripts/application.js on lines 48..50
              public/javascripts/application.js on lines 52..54

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

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

                def as_json(options = nil)
                  return super if options
              
                  json = super(:except => [:job_id, :target, :output_log_file])
                  if json["options"]
              Severity: Minor
              Found in models/transporter_job.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 ls has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def ls(path, options = {})
                  roots = options[:root] ? Array(options[:root]) : root_directory
                  return roots if path.to_s.empty?
              
                  # Make sure path starts with one of the roots, checking the longest one first.
              Severity: Minor
              Found in lib/fs_util.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