panterch/ananas

View on GitHub

Showing 14 of 14 total issues

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

    if (days.eq(dayIndex).hasClass('today')) {
      months.eq(monthIndex).removeClass('past');
      months.eq(monthIndex).removeClass('future');
      months.eq(monthIndex).addClass('today');
    };
Severity: Major
Found in app/assets/javascripts/timeline.js and 2 other locations - About 2 hrs to fix
app/assets/javascripts/timeline.js on lines 129..133
app/assets/javascripts/timeline.js on lines 134..138

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

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 3 locations. Consider refactoring.
Open

    if(days.eq(dayIndex).hasClass('future')) {
      months.eq(monthIndex).removeClass('past');
      months.eq(monthIndex).removeClass('today');
      months.eq(monthIndex).addClass('future');
    }
Severity: Major
Found in app/assets/javascripts/timeline.js and 2 other locations - About 2 hrs to fix
app/assets/javascripts/timeline.js on lines 124..128
app/assets/javascripts/timeline.js on lines 129..133

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

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 3 locations. Consider refactoring.
Open

    if (days.eq(dayIndex).hasClass('past')) {
      months.eq(monthIndex).removeClass('today');
      months.eq(monthIndex).removeClass('future');
      months.eq(monthIndex).addClass('past');
    }
Severity: Major
Found in app/assets/javascripts/timeline.js and 2 other locations - About 2 hrs to fix
app/assets/javascripts/timeline.js on lines 124..128
app/assets/javascripts/timeline.js on lines 134..138

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

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 ($(window).scrollTop() < previousPositonsMonths[monthIndex-1]) {
      unFixMonth();
      monthIndex -= 1;
      // The index can be negative if you scroll upwards too fast, so wa have to fix it
      if (monthIndex < 0) {
Severity: Major
Found in app/assets/javascripts/timeline.js and 1 other location - About 1 hr to fix
app/assets/javascripts/timeline.js on lines 81..89

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

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 ($(window).scrollTop() < previousPositonsDays[dayIndex-1]) {
      unFixDay();
      dayIndex -= 1;
      // The index can be negative if you scroll upwards too fast, so wa have to fix it
      if (dayIndex < 0) {
Severity: Major
Found in app/assets/javascripts/timeline.js and 1 other location - About 1 hr to fix
app/assets/javascripts/timeline.js on lines 60..68

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

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

Function initMaterialize has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function initMaterialize() {
    $('form .datepicker').pickadate();
    $('.modal-trigger').leanModal();

    // collect splitted up date and time values and submit them in one
Severity: Minor
Found in app/assets/javascripts/materialize-adaptions.js - About 1 hr to fix

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

      days.each(function(index, element) {
        previousPositonsDays[index] = $(element).offset().top;
        $(element).css('left', leftMarginDay + 'px');
      });
    Severity: Major
    Found in app/assets/javascripts/timeline.js and 1 other location - About 1 hr to fix
    app/assets/javascripts/timeline.js on lines 40..43

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

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

      def initialize(user)
    
        can :read, Mentor
        can :read, Event, mentor_id: nil, team_id: nil
        can :read, Team
    Severity: Minor
    Found in app/models/ability.rb - About 1 hr to fix

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

        months.each(function(index, element) {
          previousPositonsMonths[index] = $(element).offset().top;
          $(element).css('left', leftMarginMonth + 'px');
        });
      Severity: Major
      Found in app/assets/javascripts/timeline.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/timeline.js on lines 45..48

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

      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

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

      function initImagePreviewInput() {
      
          function readURL() {
              if (this.files && this.files[0]) {
                  var name = this.name;
      Severity: Minor
      Found in app/assets/javascripts/image-preview-input.js - About 1 hr to fix

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

            if (nextElement < 110) {
              previousPositonsMonths[monthIndex] = $(window).scrollTop();
              unFixMonth();
              monthIndex += 1;
              fixMonth();
        Severity: Minor
        Found in app/assets/javascripts/timeline.js and 1 other location - About 55 mins to fix
        app/assets/javascripts/timeline.js on lines 91..96

        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

            if (nextDayElement <= 151) {
              previousPositonsDays[dayIndex] = $(window).scrollTop();
              unFixDay();
              dayIndex += 1;
              fixDay();
        Severity: Minor
        Found in app/assets/javascripts/timeline.js and 1 other location - About 55 mins to fix
        app/assets/javascripts/timeline.js on lines 70..75

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

          def initialize(user)
        
            can :read, Mentor
            can :read, Event, mentor_id: nil, team_id: nil
            can :read, Team
        Severity: Minor
        Found in app/models/ability.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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def update
            # Don't try to update password if not provided
            if user_params[:password].blank?
              [:password, :password_confirmation].collect{|p| user_params.delete(p) }
            end
        Severity: Minor
        Found in app/controllers/users_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

        Severity
        Category
        Status
        Source
        Language