vj4/ui/components/calendar/index.js

Summary

Maintainability
F
3 days
Test Coverage

Function buildBodyData has 179 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  buildBodyData() {
    const now = moment();
    const days = [];
    {
      // back fill
Severity: Major
Found in vj4/ui/components/calendar/index.js - About 7 hrs to fix

    File index.js has 338 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import _ from 'lodash';
    import moment from 'moment';
    import tpl from 'vj/utils/tpl';
    
    export default class Calendar {
    Severity: Minor
    Found in vj4/ui/components/calendar/index.js - About 4 hrs to fix

      Function layout has 83 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            .map(banners => {
              const dayBitmap = _
                .fill(new Array(7), 1)
                .map(() => []);
              banners.forEach(banner => {
      Severity: Major
      Found in vj4/ui/components/calendar/index.js - About 3 hrs to fix

        Function buildBodyData has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

          buildBodyData() {
            const now = moment();
            const days = [];
            {
              // back fill
        Severity: Minor
        Found in vj4/ui/components/calendar/index.js - 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

        Function buildBody has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          buildBody() {
            const data = this.buildBodyData();
            const $body = $('<div class="calendar__body"></div>');
            data.forEach(week => {
              const $row = $(tpl`<div class="calendar__row">
        Severity: Major
        Found in vj4/ui/components/calendar/index.js - About 2 hrs to fix

          Function constructor has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            constructor(events) {
              this.$dom = $(tpl`
                <div class="calendar">
                  <div class="calendar__header">
                    <button name="prev"><span class="icon icon-chevron_left"></span></button>
          Severity: Minor
          Found in vj4/ui/components/calendar/index.js - About 1 hr to fix

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

              async updateBody(direction) {
                this.animating = true;
                const $newBody = this.buildBody();
                $newBody.appendTo(this.$dom.find('.calendar__body-container'));
                if (this.$lastBody !== null) {
            Severity: Minor
            Found in vj4/ui/components/calendar/index.js - About 1 hr to fix

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

                      for (let i = dayOfWeek; i < 6; ++i) {
                        days.push({
                          active: false,
                          date: base.add(1, 'days').clone(),
                        });
              Severity: Major
              Found in vj4/ui/components/calendar/index.js and 1 other location - About 1 hr to fix
              vj4/ui/components/calendar/index.js on lines 176..181

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

              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

                      for (let i = dayOfWeek; i > 0; --i) {
                        days.push({
                          active: false,
                          date: base.add(1, 'days').clone(),
                        });
              Severity: Major
              Found in vj4/ui/components/calendar/index.js and 1 other location - About 1 hr to fix
              vj4/ui/components/calendar/index.js on lines 200..205

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

              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 (bannerSpan.banner.beginTrunc) {
                          $banner.addClass('is-trunc-begin');
                        } else if (bannerSpan.banner.beginSnap) {
                          $banner.addClass('is-snap-begin');
                        }
              Severity: Minor
              Found in vj4/ui/components/calendar/index.js and 1 other location - About 55 mins to fix
              vj4/ui/components/calendar/index.js on lines 152..156

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

              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 (bannerSpan.banner.endTrunc) {
                          $banner.addClass('is-trunc-end');
                        } else if (bannerSpan.banner.endSnap) {
                          $banner.addClass('is-snap-end');
                        }
              Severity: Minor
              Found in vj4/ui/components/calendar/index.js and 1 other location - About 55 mins to fix
              vj4/ui/components/calendar/index.js on lines 147..151

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

              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 (ev.endAt.hour() <= 2) {
                      ev.endAt.subtract(1, 'day').endOf('day');
                    }
              Severity: Minor
              Found in vj4/ui/components/calendar/index.js and 1 other location - About 35 mins to fix
              vj4/ui/components/calendar/index.js on lines 228..230

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

              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 (ev.beginAt.hour() >= 22) {
                      ev.beginAt.add(1, 'day').startOf('day');
                    }
              Severity: Minor
              Found in vj4/ui/components/calendar/index.js and 1 other location - About 35 mins to fix
              vj4/ui/components/calendar/index.js on lines 231..233

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

              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

              There are no issues that match your filters.

              Category
              Status