v0ltoz/react-datetimepicker

View on GitHub

Showing 26 of 74 total issues

Function render has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    let selectingModeFrom = this.props.selectingModeFrom;
    let mode = this.props.mode;
    let startDotStyle =
      this.props.style && this.props.style.fromDot ? this.props.style.fromDot : { backgroundColor: '#12bc00' };
Severity: Minor
Found in src/lib/date_picker/ActiveNotifier.jsx - 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 keyboardCellCallback has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  keyboardCellCallback(originalDate, newDate) {
    let startDate;
    let endDate;
    // If original date same as start and end date, and not in smart mode
    // Then if cell end called allow new end date. Allow new start if cell start called
Severity: Minor
Found in src/lib/DateTimeRangePicker.jsx - 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 styleCellNonMouseEnter has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  styleCellNonMouseEnter() {
    let cellDay = this.props.cellDay;
    let date = this.props.date;
    let otherDate = this.props.otherDate;

Severity: Minor
Found in src/lib/calendar/Cell.jsx - 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 keyDown has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  keyDown(e) {
    let componentFocused = document.activeElement === ReactDOM.findDOMNode(this.cell);
    if (componentFocused && e.keyCode >= 37 && e.keyCode <= 40) {
      e.preventDefault();
      let newDate = moment(this.props.cellDay);
Severity: Minor
Found in src/lib/calendar/Cell.jsx - 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 propValidation has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export const propValidation = props => {
  if (props.years) {
    if (!Array.isArray(props.years)) {
      return 'Year props should be an array e.g. [2019, 2020]';
    }
Severity: Minor
Found in src/lib/utils/PropValidation.js - 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 updateTime has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  updateTime(origDate, newHour, newMinute, mode, stateDateToChangeName, stateLabelToChangeName) {
    let date = moment(origDate);
    date.hours(newHour);
    date.minutes(newMinute);
    // If Past Max Date Dont allow update
Severity: Minor
Found in src/lib/DateTimeRangePicker.jsx - 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 componentDidUpdate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  componentDidUpdate(prevProps, prevState) {
    if (this.props !== prevProps) {
      let focused = this.props.focused[this.props.index];
      if (this.props.index === this.props.selectedRange || focused) {
        this.setRangeSelectedStyle();
Severity: Minor
Found in src/lib/ranges/RangeButton.jsx - 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 getDaysBeforeStartMonday has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const getDaysBeforeStartMonday = firstDayOfMonth => {
  let fourtyTwoDays = [];
  let dayBeforeFirstDayOfMonth = firstDayOfMonth.day() - 1; // We dont want to include the first day of the new month
  // Case whereby day before is a Saturday (6) and we require Saturday back to Monday for that week
  if (dayBeforeFirstDayOfMonth === -1) {
Severity: Minor
Found in src/lib/utils/TimeFunctionUtils.js - 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

Function createYears has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export const createYears = (userDefinedYears, descendingYears) => {
  let years = [];
  if (!userDefinedYears) {
    //Range from 1900 to 25 years into the future
    let past = moment('19000101', 'YYYYMMDD');
Severity: Minor
Found in src/lib/utils/YearUtils.js - 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

Function browserVersion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const browserVersion = () => {
  let ua = navigator.userAgent,
    tem,
    M =
      ua.match(
Severity: Minor
Found in src/lib/utils/BrowserVersion.js - 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

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

function workOutMonthYear(date, secondDate, mode, pastSearchFriendly, smartMode) {
Severity: Minor
Found in src/lib/utils/TimeFunctionUtils.js - About 35 mins to fix

    Function updateDate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      updateDate(
        mode,
        newDate,
        isValidNewDate,
        isValidDateChange,
    Severity: Minor
    Found in src/lib/DateTimeRangePicker.jsx - 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

    Function renderButtons has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      renderButtons() {
        let applyButton;
        let closeButtonText = (this.props.local && this.props.local.close) ? this.props.local.close : 'Close';
        if (!this.props.autoApply) {
          applyButton = this.renderButton(
    Severity: Minor
    Found in src/lib/date_picker/ApplyCancelButtons.jsx - 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

    Function componentDidUpdate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      componentDidUpdate(oldProps) {
        let isDifferentMomentObject = !oldProps.date.isSame(this.props.date) || !oldProps.otherDate.isSame(this.props.otherDate);
        let isDifferentTime = this.props.date.format('DD-MM-YYYY HH:mm') !== oldProps.date.format('DD-MM-YYYY HH:mm') || this.props.otherDate.format('DD-MM-YYYY HH:mm') !== oldProps.otherDate.format('DD-MM-YYYY HH:mm')
    
        if (isDifferentMomentObject || isDifferentTime) {
    Severity: Minor
    Found in src/lib/calendar/Cell.jsx - 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

    Avoid too many return statements within this function.
    Open

        return false;
    Severity: Major
    Found in src/lib/utils/BrowserVersion.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return 'End year should be in the custom years defined';
      Severity: Major
      Found in src/lib/utils/PropValidation.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return <div />;
        Severity: Major
        Found in src/lib/date_picker/ActiveNotifier.jsx - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            return true;
          Severity: Major
          Found in src/lib/utils/PropValidation.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

              return false;
            Severity: Major
            Found in src/lib/utils/BrowserVersion.js - About 30 mins to fix

              Function shouldStyleCellStartEnd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                shouldStyleCellStartEnd(cellDay, date, otherDate, startCheck, endCheck) {
                  let isCellDateProp = cellDay.isSame(date, 'day');
                  let isCellOtherDateProp = cellDay.isSame(otherDate, 'day');
                  let isDateStart = date.isSameOrBefore(otherDate, 'second');
                  let isOtherDateStart = otherDate.isSameOrBefore(date, 'second');
              Severity: Minor
              Found in src/lib/calendar/Cell.jsx - About 25 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