joshsoftware/code-curiosity

View on GitHub

Showing 64 of 64 total issues

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

                else {
                    $input.prop('checked', false);

                    if (this.options.selectedClass) {
                        $input.closest('li')
Severity: Major
Found in app/assets/javascripts/bootstrap-multiselect.js and 1 other location - About 1 hr to fix
app/assets/javascripts/bootstrap-multiselect.js on lines 944..951

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

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

                if ($(element).is(':selected')) {
                    $input.prop('checked', true);

                    if (this.options.selectedClass) {
                        $input.closest('li')
Severity: Major
Found in app/assets/javascripts/bootstrap-multiselect.js and 1 other location - About 1 hr to fix
app/assets/javascripts/bootstrap-multiselect.js on lines 952..959

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

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

  def add_repo(gh_repo)
    repo = Repository.new(name: gh_repo.name, owner: gh_repo.owner.login)
    info = gh_repo.fork ? repo.info.source : gh_repo

    #check if the repository is not soft deleted and
Severity: Minor
Found in app/jobs/user_repos_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

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

    function Multiselect(select, options) {

        this.$select = $(select);
        
        // Placeholder via data attributes
Severity: Minor
Found in app/assets/javascripts/bootstrap-multiselect.js - About 1 hr to fix

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

                var buildWidget = function() {
                    var $w = $('<div />', { 'class': 'br-widget' });
    
                    // create A elements that will replace OPTIONs
                    self.$elem.find('option').each(function() {
    Severity: Minor
    Found in app/assets/javascripts/jquery.barrating.js - About 1 hr to fix

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

              selectAll: function (justVisible, triggerOnSelectAll) {
                  var justVisible = typeof justVisible === 'undefined' ? true : justVisible;
                  var allCheckboxes = $("li input[type='checkbox']:enabled", this.$ul);
                  var visibleCheckboxes = allCheckboxes.filter(":visible");
                  var allCheckboxesCount = allCheckboxes.length;
      Severity: Minor
      Found in app/assets/javascripts/bootstrap-multiselect.js - About 1 hr to fix

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

                    buttonText: function(options, select) {
                        if (options.length === 0) {
                            return this.nonSelectedText;
                        }
                        else if (this.allSelectedText 
        Severity: Minor
        Found in app/assets/javascripts/bootstrap-multiselect.js - About 1 hr to fix

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

            def create
              gh_repo = Repository.new(repo_params).info
              repo = gh_repo && !gh_repo.fork ? Repository.build_from_gh_info(gh_repo) : false
          
              if repo && repo.save
          Severity: Minor
          Found in app/controllers/admin/repositories_controller.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 perform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def perform(repo_owner: , repo_name: , branch_name: , **options)
              from_date = options[:from_date].presence || Date.yesterday.beginning_of_day
              to_date = options[:to_date].presence || Date.yesterday.end_of_day
          
              Sidekiq.logger.info "************************ Commit Job Logger Info **************************"
          Severity: Minor
          Found in app/jobs/fetch_commit_job.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

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

                  disable: function() {
                      this.$select.prop('disabled', true);
                      this.$button.prop('disabled', true)
                          .addClass('disabled');
                  },
          Severity: Minor
          Found in app/assets/javascripts/bootstrap-multiselect.js and 1 other location - About 50 mins to fix
          app/assets/javascripts/bootstrap-multiselect.js on lines 1237..1241

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

          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

                  enable: function() {
                      this.$select.prop('disabled', false);
                      this.$button.prop('disabled', false)
                          .removeClass('disabled');
                  },
          Severity: Minor
          Found in app/assets/javascripts/bootstrap-multiselect.js and 1 other location - About 50 mins to fix
          app/assets/javascripts/bootstrap-multiselect.js on lines 1246..1250

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

          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

          Avoid deeply nested control flow statements.
          Open

                  } else if (value) {
                    buffer += renderTokens(token[4], writer, context, template);
                  }
          Severity: Major
          Found in app/assets/javascripts/mustache.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      } else if (value) {
                        buffer += renderTokens(token[4], writer, context.push(value), template);
                      }
            Severity: Major
            Found in app/assets/javascripts/mustache.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                          for (var j = 0, jlen = value.length; j < jlen; ++j) {
                            buffer += renderTokens(token[4], writer, context.push(value[j]), template);
                          }
              Severity: Major
              Found in app/assets/javascripts/mustache.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                                        if (this.options.enableCaseInsensitiveFiltering && filterCandidate.toLowerCase().indexOf(this.query.toLowerCase()) > -1) {
                                                            showElement = true;
                                                        }
                                                        else if (filterCandidate.indexOf(this.query) > -1) {
                                                            showElement = true;
                Severity: Major
                Found in app/assets/javascripts/bootstrap-multiselect.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                                          if ($(element).hasClass('multiselect-group')) {
                                                              // Remember group status.
                                                              currentGroup = element;
                                                              currentGroupVisible = showElement;
                                                          }
                  Severity: Major
                  Found in app/assets/javascripts/bootstrap-multiselect.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                              if (value != null) buffer += value;
                    Severity: Major
                    Found in app/assets/javascripts/mustache.js - About 45 mins to fix

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

                                  init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
                      Severity: Minor
                      Found in app/assets/javascripts/bootstrap-multiselect.js - About 35 mins to fix

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

                                    update: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
                        Severity: Minor
                        Found in app/assets/javascripts/bootstrap-multiselect.js - About 35 mins to fix

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

                              def get
                                contributions = Commit.collection.aggregate([match, project, group, sort])
                                contributions.collect do |r|
                                  [
                                    "#{Date::ABBR_MONTHNAMES[r['_id']['month']]} #{r['_id']['year']}",
                          Severity: Minor
                          Found in app/services/multi_line_chart/contribution.rb and 1 other location - About 35 mins to fix
                          app/services/multi_line_chart/user.rb on lines 3..9

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

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language