Innqube/ngx-iq-datepicker

View on GitHub

Showing 41 of 41 total issues

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

    it('should update calendar hours after entering it as text', fakeAsync(() => {
        let parent = TestBed.createComponent(TestHostComponentWithTime);
        parent.detectChanges();
        const component = parent.componentInstance;
        component.datePicker.calendarVisible = true;
src/app/component-wrapper/src/app/iq-datepicker/iq-datepicker.component.spec.ts on lines 202..215

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

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

    it('should update calendar minutes after entering it as text', fakeAsync(() => {
        let parent = TestBed.createComponent(TestHostComponentWithTime);
        parent.detectChanges();
        const component = parent.componentInstance;
        component.datePicker.calendarVisible = true;
src/app/component-wrapper/src/app/iq-datepicker/iq-datepicker.component.spec.ts on lines 187..200

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

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

    it('should update calendar month after entering as text', fakeAsync(() => {
        component.calendarVisible = true;
        fixture.detectChanges();
        const input = fixture.nativeElement.querySelector('input');
        input.value = '1985-11-14';
src/app/component-wrapper/src/app/iq-datepicker/iq-datepicker.component.spec.ts on lines 167..175

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

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

    it('should update calendar year after entering as text', fakeAsync(() => {
        component.calendarVisible = true;
        fixture.detectChanges();
        const input = fixture.nativeElement.querySelector('input');
        input.value = '14/11/1985';
src/app/component-wrapper/src/app/iq-datepicker/iq-datepicker.component.spec.ts on lines 177..185

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

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

    prevMonth() {
        const currentMonth = this.date.getMonth();

        if (currentMonth === 0) {
            this.date.setMonth(11);
src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.ts on lines 66..77

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

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

    nextMonth() {
        const currentMonth = this.date.getMonth();

        if (currentMonth === 11) {
            this.date.setMonth(0);
src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.ts on lines 53..64

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

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

File iq-datepicker.component.spec.ts has 283 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing';

import {IqDatepickerComponent} from './iq-datepicker.component';
import {FormBuilder, FormGroup, ReactiveFormsModule} from '@angular/forms';
import {IqDatepickerEnglishTranslation} from './iq-datepicker-english-translation';

    IqDatepickerComponent has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    @Component({
        selector: 'iq-datepicker',
        templateUrl: './iq-datepicker.component.html',
        styleUrls: ['./iq-datepicker.component.css'],
        providers: [VALUE_ACCESSOR]

      IqCalendarComponent has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      @Component({
          selector: 'iq-calendar',
          templateUrl: './iq-calendar.component.html',
          styleUrls: ['./iq-calendar.component.css']
      })

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

            it('should disable clear button', () => {
                let parent = TestBed.createComponent(TestHostComponentDisabled);
                parent.detectChanges();
                const selector = parent.nativeElement.querySelector('button');
                expect(selector.disabled).toBeTruthy();
        src/app/component-wrapper/src/app/iq-datepicker/iq-datepicker.component.spec.ts on lines 102..107

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

        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

            it('should disable input', () => {
                let parent = TestBed.createComponent(TestHostComponentDisabled);
                parent.detectChanges();
                const selector = parent.nativeElement.querySelector('input');
                expect(selector.disabled).toBeTruthy();
        src/app/component-wrapper/src/app/iq-datepicker/iq-datepicker.component.spec.ts on lines 109..114

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

        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 (hours && hours >= 0 && hours <= 23) {
                    this.date.setHours(hours);
                    hoursStr = hours < 10 ? '0' + hours : String(hours);
                } else {
                    hoursStr = '00';
        src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.ts on lines 217..222

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

        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 (minutes && minutes >= 0 && minutes <= 59) {
                    this.date.setMinutes(minutes);
                    minutesStr = minutes < 10 ? '0' + minutes : String(minutes);
                } else {
                    minutesStr = '00';
        src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.ts on lines 203..208

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

        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

            it('should start with hidden calendar', () => {
                const selectors = fixture.nativeElement.querySelectorAll('button');
                selectors[1].dispatchEvent(new Event('click'));
                expect(component.calendarVisible).toBeTruthy();
            });
        src/app/component-wrapper/src/app/iq-datepicker/iq-datepicker.component.spec.ts on lines 69..73

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

        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

            it('should show calendar when calendar button is clicked', () => {
                const selectors = fixture.nativeElement.querySelectorAll('button');
                selectors[1].dispatchEvent(new Event('click'));
                expect(component.calendarVisible).toBeTruthy();
            });
        src/app/component-wrapper/src/app/iq-datepicker/iq-datepicker.component.spec.ts on lines 63..67

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

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

            ngOnInit() {
                this.setDefaults();
                this.buildDateMask();
                this.selectedDateInput
                    .valueChanges

          Function exports has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function (config) {
            config.set({
              basePath: '',
              frameworks: ['jasmine', '@angular/cli'],
              plugins: [
          Severity: Minor
          Found in karma.conf.js - About 1 hr to fix

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

                it('should go to previous year if visible month is january', () => {
                    component.date = new Date(2017, 0, 1);
                    component.prevMonth();
                    expect(component.date.getFullYear()).toBe(2016);
                });
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 34..38
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 46..50
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 52..56
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 58..62
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 64..68
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 70..74
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 76..80

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

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

                it('should go to next month', () => {
                    component.date = new Date(2017, 5, 1);
                    component.nextMonth();
                    expect(component.date.getMonth()).toBe(6);
                });
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 34..38
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 40..44
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 46..50
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 58..62
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 64..68
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 70..74
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 76..80

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

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

                it('should go to first month if visible month is december', () => {
                    component.date = new Date(2017, 11, 1);
                    component.nextMonth();
                    expect(component.date.getMonth()).toBe(0);
                });
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 34..38
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 40..44
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 46..50
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 52..56
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 58..62
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 70..74
            src/app/component-wrapper/src/app/iq-calendar/iq-calendar.component.spec.ts on lines 76..80

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

            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