woese/guara-crm

View on GitHub

Showing 48 of 101 total issues

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

  def initialize(user)
    
    user ||= User.new # guest user (not logged in)
    if user.admin?
      can :manage, :all
Severity: Minor
Found in app/models/ability.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 build_menu_items has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def build_menu_items(menu)
    returns = ""
    menu[:items].each do |item|
      rails_model = item.to_s.titlecase.gsub(' ','').singularize.to_sym
      
Severity: Minor
Found in app/helpers/menu_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

Function _updateDateTime has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    _updateDateTime: function(dp_inst) {
        dp_inst = this.inst || dp_inst;
        var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
            dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
            formatCfg = $.datepicker._getFormatConfig(dp_inst),
Severity: Minor
Found in app/assets/javascripts/jquery-ui-timepicker-addon.js - About 1 hr to fix

    Function addItem has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                function addItem(title, value, preadded, locked, focusme) {
                    if (!maxItems()) {
                        return false
                    }
                    var liclass = "bit-box" + (locked ? " locked": "");
    Severity: Minor
    Found in app/assets/javascripts/fcbk.js - About 1 hr to fix

      Function load_feed has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  function load_feed(etext) {
                      counter = 0;
                      if (options.json_url && maxItems()) {
                          if (options.cache && json_cache_object.get(etext)) {
                              addMembers(etext);
      Severity: Minor
      Found in app/assets/javascripts/fcbk.js - About 1 hr to fix

        Function _doKeyPress has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        $.datepicker._doKeyPress = function(event) {
            var inst = $.datepicker._getInst(event.target),
                tp_inst = $.datepicker._get(inst, 'timepicker');
        
            if (tp_inst) {
        Severity: Minor
        Found in app/assets/javascripts/jquery-ui-timepicker-addon.js - About 1 hr to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (h == 0) tmph = 12 +'a';
                                  else if (h < 12) tmph += 'a';
                                  else tmph += 'p';
          Severity: Major
          Found in app/assets/javascripts/jquery-ui-timepicker-addon.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        } else if (aph == 12) h = 12;
                                        else h = aph + 12;
            Severity: Major
            Found in app/assets/javascripts/jquery-ui-timepicker-addon.js - About 45 mins to fix

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

                  def migrate!
                  
                    raise "schema_from needs" if @schema_from.nil?
                    raise "schema_to needs" if @schema_to.nil?
                    
              Severity: Minor
              Found in lib/active_migration/migration.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

              Avoid deeply nested control flow statements.
              Open

                                              if (aph == 12) h = 0;
                                              else h = aph;
              Severity: Major
              Found in app/assets/javascripts/jquery-ui-timepicker-addon.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if(this.millisec < this._defaults.millisecMin)
                                            this.millisec = this._defaults.millisecMin;
                Severity: Major
                Found in app/assets/javascripts/jquery-ui-timepicker-addon.js - About 45 mins to fix

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

                    def self.search_by_params(results=nil, query)
                      
                      results = self.send(:relation) if results.nil?
                      where = {}
                      
                  Severity: Minor
                  Found in app/models/contact.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

                  Avoid deeply nested control flow statements.
                  Open

                                          if(this.millisec > this._defaults.millisecMax) this.millisec = this._defaults.millisecMax;
                  Severity: Major
                  Found in app/assets/javascripts/jquery-ui-timepicker-addon.js - About 45 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                                            if ((_key.exclamation <= charcode && charcode <= _key.slash) || (_key.colon <= charcode && charcode <= _key.at) || (_key.squarebricket_left <= charcode && charcode <= _key.apostrof)) {
                                                string = string.replace(string[i], escape(string[i]))
                                            }
                    Severity: Major
                    Found in app/assets/javascripts/fcbk.js - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                            unless (!record.complete? && ((value == "") || (value == '0'*14) || (Cnpj.new(value).valido?))) || 
                                   (Cnpj.new(value).valido?)
                              record.errors[attribute] << (options[:message] || ("%s %s" % [I18n.t("customer_pjs.doc"), I18n.t('errors.messages.invalid')]) )
                            end
                      Severity: Major
                      Found in app/validators/customer_cnpj_validator.rb - About 40 mins to fix

                        Function addItem has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                    function addItem(title, value, preadded, locked, focusme) {
                        Severity: Minor
                        Found in app/assets/javascripts/fcbk.js - About 35 mins to fix

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

                              def due_critical_level
                                
                                return 0 if done? || due_time.nil?
                                
                                if (due_time>Time.now)
                          Severity: Minor
                          Found in app/models/task.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 load_form has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def load_form
                              #remove conficts
                              feedback_params = params[:task][:feedbacks]
                              params[:task].delete :feedbacks
                              
                          Severity: Minor
                          Found in app/controllers/tasks_controller.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 validate_each has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                            def validate_each(record, attribute, value)
                              
                              if (record.person_type==CustomerPj.to_s)
                                
                                #cnpj
                          Severity: Minor
                          Found in app/validators/customer_cnpj_validator.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

                          Avoid too many return statements within this method.
                          Open

                                    return
                          Severity: Major
                          Found in lib/active_migration/converters/rtf_to_html.rb - About 30 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language