AgileVentures/WebsiteOne

View on GitHub

Showing 63 of 206 total issues

Function hightlight has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        return function hightlight(o) {
            var regex;
            o = _.mixin({}, defaults, o);
            if (!o.node || !o.pattern) {
                return;
Severity: Minor
Found in app/assets/javascripts/typeahead.jquery.js - About 1 hr to fix

Function updateNavArrows has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        updateNavArrows: function(){
            if (!this._allow_update)
                return;

            var d = new Date(this.viewDate),
Severity: Minor
Found in app/assets/javascripts/bootstrap-datepicker.js - About 1 hr to fix

Function dateUpdated has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        dateUpdated: function(e){
            // `this.updating` is a workaround for preventing infinite recursion
            // between `changeDate` triggering and `setUTCDate` calling.  Until
            // there is a better mechanism.
            if (this.updating)
Severity: Minor
Found in app/assets/javascripts/bootstrap-datepicker.js - About 1 hr to fix

Function set has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  NProgress.set = function(n) {
    var started = NProgress.isStarted();

    n = clamp(n, Settings.minimum, 1);
    NProgress.status = (n === 1 ? null : n);
Severity: Minor
Found in app/assets/javascripts/nprogress.js - About 1 hr to fix

Function Input has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function Input(o, www) {
            var id;
            o = o || {};
            if (!o.input) {
                $.error("input is missing");
Severity: Minor
Found in app/assets/javascripts/typeahead.jquery.js - About 1 hr to fix

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

  def update_user_commit_counts_for(project)
    contributors = get_contributor_stats(project.github_repo)

    contributors.map do |contributor|
      user = User.find_by_github_username(contributor.author.login)
Severity: Minor
Found in app/jobs/github_commits_job.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 display_countdown has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def display_countdown(event)
    time_to_next_event_instance = Time.now.to_datetime.distance_to(event.next_occurrence_time_attr.to_datetime)
    minutes_left = time_to_next_event_instance[:minutes]
    hours_left = time_to_next_event_instance[:hours]
    days_left = time_to_next_event_instance[:days]
Severity: Minor
Found in app/helpers/visitors_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 AffixedNavbar has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function AffixedNavbar() {
    var isAffixed, affixedNav, header, main, footer, thresholdTop,
        isListening = false;

    this.onScroll = function() {
Severity: Minor
Found in app/assets/javascripts/global-modules/affix_navbar.js - About 1 hr to fix

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

        formatDate: function(date, format, language){
            if (!date)
                return '';
            if (typeof format === 'string')
                format = DPGlobal.parseFormat(format);
Severity: Minor
Found in app/assets/javascripts/bootstrap-datepicker.js - About 1 hr to fix

Function _fill_yearsView has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

        _fill_yearsView: function(selector, cssClass, factor, year, startYear, endYear, beforeFn){
Severity: Major
Found in app/assets/javascripts/bootstrap-datepicker.js - About 50 mins to fix

Avoid deeply nested control flow statements.
Open

            if (e.keyCode === 38 || e.keyCode === 40) {
              dir = dir * 4;
            }
Severity: Major
Found in app/assets/javascripts/bootstrap-datepicker.js - About 45 mins to fix

Method with has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def self.with(user, sponsor, time, plan, payment_source, subscription_klass = Subscription)
Severity: Minor
Found in app/services/add_subscription_to_user_for_plan.rb - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                      } else if (e.keyCode === 37 || e.keyCode === 39){
                          newViewDate = this.moveAvailableDate(focusDate, dir, 'moveDay');
                      } else if (!this.weekOfDateIsDisabled(focusDate)){
                          newViewDate = this.moveAvailableDate(focusDate, dir, 'moveWeek');
                      }
Severity: Major
Found in app/assets/javascripts/bootstrap-datepicker.js - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                          if (newViewDate)
                              this._trigger('changeMonth', this.viewDate);
Severity: Major
Found in app/assets/javascripts/bootstrap-datepicker.js - About 45 mins to fix

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

  def remove_from_schedule(timedate)
    # best if schedule is serialized into the events record...  and an attribute.
    if timedate >= Time.now && timedate == next_occurrence_time_method
      _next_occurrences = next_occurrences(limit: 2)
      self.start_datetime = _next_occurrences.size > 1 ? _next_occurrences[1][:time] : timedate + 1.day
Severity: Minor
Found in app/models/event.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 destroy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def destroy
    @authentication = current_user.authentications.find(params[:id])
    if @authentication && (current_user.authentications.count == 1) && current_user.encrypted_password.blank?
      flash[:alert] = 'Failed to unlink GitHub. Please use another provider for login or reset password.'
    elsif @authentication&.destroy
Severity: Minor
Found in app/controllers/authentications_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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    omniauth = request.env['omniauth.auth']
    authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
    @path = request.env['omniauth.origin'] || root_path
    if authentication.present?
Severity: Minor
Found in app/controllers/authentications_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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    # "user_slug"=>"<slug>", "subscription"=>{"plan_id"=>"12"},
    # "commit"=>"Adjust Level", "controller"=>"subscriptions", "action"=>"update", "id"=>"45"} permitted: false>
    begin
      plan = Plan.find params[:subscription][:plan_id]
Severity: Minor
Found in app/controllers/subscriptions_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

Avoid too many return statements within this function.
Open

            return date;
Severity: Major
Found in app/assets/javascripts/bootstrap-datepicker.js - About 30 mins to fix

Method process_markdown_pages has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def process_markdown_pages(md_pages)
    md_pages.each do |page|
      filename = page[:path]
      page_content = client.contents('agileventures/agileventures', path: filename)
      markdown = Base64.decode64(page_content[:content])
Severity: Minor
Found in app/jobs/github_static_pages_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

Severity
Category
Status
Source
Language