hisptz/function-analytics

View on GitHub

Showing 76 of 76 total issues

File period-instance.js has 663 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { chunk, head, last, range } from 'lodash';

import { Calendar } from './calendars/calendar';

export class PeriodInstance {
Severity: Major
Found in src/utilities/period-instance.js - About 1 day to fix

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

      fromJD(f) {
        const z = Math.floor(f + 0.5);
        let a = Math.floor((z - 1867216.25) / 36524.25);
    
        a = z + 1 + a - Math.floor(a / 4);
    Severity: Major
    Found in src/utilities/calendars/gregorian-calendar.js and 1 other location - About 1 day to fix
    src/utilities/calendars/base-calendar.js on lines 329..346

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

    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

      fromJD(f) {
        const z = Math.floor(f + 0.5);
        const a = Math.floor((z - 1867216.25) / 36524.25);
    
        a = z + 1 + a - Math.floor(a / 4);
    Severity: Major
    Found in src/utilities/calendars/base-calendar.js and 1 other location - About 1 day to fix
    src/utilities/calendars/gregorian-calendar.js on lines 122..139

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

    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

      toJD(c, d, e) {
        const f = this._validate(c, d, e, this._invalids.invalidDate);
    
        c = f.year();
        d = f.month();
    Severity: Major
    Found in src/utilities/calendars/gregorian-calendar.js and 1 other location - About 1 day to fix
    src/utilities/calendars/base-calendar.js on lines 305..328

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

    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

      toJD(c, d, e) {
        const f = this._validate(c, d, e, this._invalids.invalidDate);
    
        c = f.year();
        d = f.month();
    Severity: Major
    Found in src/utilities/calendars/base-calendar.js and 1 other location - About 1 day to fix
    src/utilities/calendars/gregorian-calendar.js on lines 98..121

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

    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

      getBiMonthlyPeriods(year) {
        return (chunk(this._monthNames || [], 2) || []).map(
          (biMonths, biMonthIndex) => {
            const id = this.getBiMonthlyPeriodId(year, biMonthIndex + 1);
    
    
    Severity: Major
    Found in src/utilities/period-instance.js and 1 other location - About 7 hrs to fix
    src/utilities/period-instance.js on lines 375..407

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

    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

      getSixMonthlyPeriods(year) {
        return (chunk(this._monthNames || [], 6) || []).map(
          (sixMonths, sixMonthIndex) => {
            const id = this.getSixMonthlyPeriodId(year, sixMonthIndex + 1);
    
    
    Severity: Major
    Found in src/utilities/period-instance.js and 1 other location - About 7 hrs to fix
    src/utilities/period-instance.js on lines 341..373

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

    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

        return (
          chunk([...months.slice(3), ...months.slice(0, 3)] || [], 6) || []
        ).map((sixMonthApril, sixMonthAprilIndex) => {
          const id = this.getSixMonthlyPeriodId(
            year,
    Severity: Major
    Found in src/utilities/period-instance.js and 1 other location - About 5 hrs to fix
    src/utilities/period-instance.js on lines 452..492

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

    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

        return chunk(
          this.getMonthsByOffset(
            this.getMonthWithYears(this._monthNames, year, -2),
            this._quarterMonthOffset
          ),
    Severity: Major
    Found in src/utilities/period-instance.js and 1 other location - About 5 hrs to fix
    src/utilities/period-instance.js on lines 412..448

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

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

      static deducePeriodType(periodId) {
        let periodType;
    
        const numberLikePeriod = parseInt(periodId, 10);
    
    
    Severity: Minor
    Found in src/utilities/period-util.js - About 3 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 getChildrenPeriods has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      getChildrenPeriods(parentId, parentType, childrenType, preferences) {
        let periods = [];
    
        switch (parentType) {
          case 'Yearly': {
    Severity: Major
    Found in src/utilities/period-instance.js - About 3 hrs to fix

      Function getRelativePeriods has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        getRelativePeriods(type) {
          switch (type) {
            case 'RelativeBiMonth': {
              return [
                { id: 'THIS_BIMONTH', type, name: 'This Bi-month' },
      Severity: Major
      Found in src/utilities/period-instance.js - About 3 hrs to fix

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

          daysInMonth(a, b) {
            const c = this._validate(a, b, this._minDay, this._invalids.invalidMonth);
        
            return (
              this._daysPerMonth[c.month() - 1] +
        Severity: Major
        Found in src/utilities/calendars/gregorian-calendar.js and 1 other location - About 3 hrs to fix
        src/utilities/calendars/ethiopian-calender.js on lines 95..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 102.

        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

          daysInMonth(a, b) {
            const validDate = this._validate(
              a,
              b,
              this._minDay,
        Severity: Major
        Found in src/utilities/calendars/ethiopian-calender.js and 1 other location - About 3 hrs to fix
        src/utilities/calendars/gregorian-calendar.js on lines 82..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 102.

        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

        PeriodInstance has 27 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class PeriodInstance {
          constructor(calendarId, type, preferences, year) {
            this._calendarId = calendarId || 'gregorian';
            this._type = type;
            this._preferences = preferences;
        Severity: Minor
        Found in src/utilities/period-instance.js - About 3 hrs to fix

          CalendarDate has 27 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class CalendarDate {
            constructor(calendar, year, month, day) {
              this._calendar = calendar;
              this._year = year;
              this._month = month;
          Severity: Minor
          Found in src/utilities/calendars/calendar-date.js - About 3 hrs to fix

            File base-calendar.js has 295 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import {
              CalendarDate
            } from './calendar-date';
            
            export class BaseCalender {
            Severity: Minor
            Found in src/utilities/calendars/base-calendar.js - About 3 hrs to fix

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

                    case 'RelativeWeek': {
                      return [
                        { id: 'THIS_WEEK', type, name: 'This Week' },
                        { id: 'LAST_WEEK', type, name: 'Last Week' },
                        {
              Severity: Major
              Found in src/utilities/period-instance.js and 1 other location - About 3 hrs to fix
              src/utilities/period-instance.js on lines 164..176

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

              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

                    case 'RelativeMonth': {
                      return [
                        { id: 'THIS_MONTH', type, name: 'This Month' },
                        { id: 'LAST_MONTH', type, name: 'Last Month' },
                        {
              Severity: Major
              Found in src/utilities/period-instance.js and 1 other location - About 3 hrs to fix
              src/utilities/period-instance.js on lines 226..238

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

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

                getCurrentPeriodId(type) {
                  switch (type) {
                    case 'Monthly': {
                      return this.getMonthPeriodId(
                        this._calendar.getCurrentYear(),
              Severity: Major
              Found in src/utilities/period-instance.js - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language