cattr-app/frontend-application

View on GitHub
app/core/modules/TimeIntervals/module.init.js

Summary

Maintainability
B
4 hrs
Test Coverage

Function init has 100 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function init(context, router) {
    const crud = context.createCrud('time_intervals.crud_title', 'time-intervals', TimeIntervalService);
    const crudNewRoute = crud.new.getNewRouteName();

    crud.new.addToMetaProperties('permissions', 'time-intervals/create', crud.new.getRouterConfig());
Severity: Major
Found in app/core/modules/TimeIntervals/module.init.js - About 4 hrs to fix

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

    export function init(context, router) {
        const crud = context.createCrud('time_intervals.crud_title', 'time-intervals', TimeIntervalService);
        const crudNewRoute = crud.new.getNewRouteName();
    
        crud.new.addToMetaProperties('permissions', 'time-intervals/create', crud.new.getRouterConfig());
    Severity: Minor
    Found in app/core/modules/TimeIntervals/module.init.js - 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

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············label:·'field.user' with ······label:·"field.user"
    Open

                label: 'field.user',

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ····
    Open

            {

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Definition for rule 'vue/attributes-order' was not found
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ··moduleName:·'TimeIntervals', with moduleName:·"TimeIntervals"
    Open

        moduleName: 'TimeIntervals',

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ···· with ··
    Open

        const fieldsToFill = [

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ······key:·'task_id' with key:·"task_id"
    Open

                key: 'task_id',

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ··
    Open

        const crudNewRoute = crud.new.getNewRouteName();

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ························ with ············
    Open

                            service: new TasksService(),

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Replace '@/store' with "@/store"
    Open

    import rootStore from '@/store';

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ··
    Open

        loadOrder: 20,

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ····crud.new.addToMetaProperties('permissions',·'time-intervals/create',·crud.new.getRouterConfig()); with ··crud.new.addToMetaProperties(⏎····"permissions",⏎····"time-intervals/create",⏎····crud.new.getRouterConfig()
    Open

        crud.new.addToMetaProperties('permissions', 'time-intervals/create', crud.new.getRouterConfig());

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ··crud.new.addToMetaProperties('afterSubmitCallback',·()·=>·router.go(-1),·crud.new.getRouterConfig() with );⏎··crud.new.addToMetaProperties(⏎····"afterSubmitCallback",⏎····()·=>·router.go(-1),⏎····crud.new.getRouterConfig()⏎··
    Open

        crud.new.addToMetaProperties('afterSubmitCallback', () => router.go(-1), crud.new.getRouterConfig());

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ················ with ········
    Open

                    return h(LazySelect, {

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ····routerPrefix:·'time-intervals' with ··routerPrefix:·"time-intervals"
    Open

        routerPrefix: 'time-intervals',

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············type:·'resource-select' with ······type:·"resource-select"
    Open

                type: 'resource-select',

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ··········
    Open

                        props: {

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Replace '@/services/resource/time-interval.service' with "@/services/resource/time-interval.service"
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Replace './components/LazySelect' with "./components/LazySelect"
    Open

    import LazySelect from './components/LazySelect';

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Replace '@/services/resource/user.service' with "@/services/resource/user.service"
    Open

    import UsersService from '@/services/resource/user.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ····
    Open

            {

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Replace '@/components/TimezonePicker' with "@/components/TimezonePicker"
    Open

    import TimezonePicker from '@/components/TimezonePicker';

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ····
    Open

            },

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Replace './components/DatetimeInput' with "./components/DatetimeInput"
    Open

    import DatetimeInput from './components/DatetimeInput';

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············label:·'field.task' with ······label:·"field.task"
    Open

                label: 'field.task',

    For more information visit Source: http://eslint.org/docs/rules/

    Replace 'moment-timezone' with "moment-timezone"
    Open

    import moment from 'moment-timezone';

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············ with ······
    Open

                service: new UsersService(),

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ························ with ············
    Open

                            inputHandler: props.inputHandler,

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Use the latest vue-eslint-parser. See also https://github.com/vuejs/eslint-plugin-vue#what-is-the-use-the-latest-vue-eslint-parser-error
    Open

    import TimeIntervalService from '@/services/resource/time-interval.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Replace '@/services/resource/task.service' with "@/services/resource/task.service"
    Open

    import TasksService from '@/services/resource/task.service';

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ····const·crud·=·context.createCrud('time_intervals.crud_title',·'time-intervals',·TimeIntervalService with ··const·crud·=·context.createCrud(⏎····"time_intervals.crud_title",⏎····"time-intervals",⏎····TimeIntervalService⏎··
    Open

        const crud = context.createCrud('time_intervals.crud_title', 'time-intervals', TimeIntervalService);

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············key:·'user_id' with ······key:·"user_id"
    Open

                key: 'user_id',

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············required:·true, with ······required:·true
    Open

                required: true,

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ······
    Open

                render: (h, props) => {

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ················ with ········
    Open

                    return h(TimezonePicker, {

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ···················· with ··········
    Open

                        },

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ························timezone:·props.values.timezone, with ············timezone:·props.values.timezone
    Open

                            timezone: props.values.timezone,

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ···························· with ··············
    Open

                                // Set is_manual for task here, because it`s stupid to fill it manually each time

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············ with ······
    Open

                },

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ····
    Open

            },

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············key:·'end_at' with ······key:·"end_at"
    Open

                key: 'end_at',

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ········
    Open

                    });

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ········}, with ····}
    Open

            },

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············key:·'timezone' with ······key:·"timezone"
    Open

                key: 'timezone',

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ············
    Open

                            change: value => {

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············required:·true, with ······required:·true
    Open

                required: true,

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ····················}, with ··········}
    Open

                        },

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ········ with ····
    Open

            },

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ······
    Open

                render: (h, props) => {

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ··············?·moment(props.currentValue).tz(props.values.timezone,·true) with ?·moment(props.currentValue)⏎··············.tz(props.values.timezone,·true)⏎··············
    Open

                            ? moment(props.currentValue).tz(props.values.timezone, true).toISOString()

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ····················}, with ··········}
    Open

                        },

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ················ with ········
    Open

                    });

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ····················}, with ··········}
    Open

                        },

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············ with ······
    Open

                },

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ················ with ········
    Open

                    });

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ····························rootStore.commit('dashboard/setTimezone' with ··············rootStore.commit("dashboard/setTimezone"
    Open

                                rootStore.commit('dashboard/setTimezone', value);

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ··············value·=·moment(value).add(10,·'minutes' with value·=·moment(value).add(10,·"minutes"
    Open

                                value = moment(value).add(10, 'minutes').toISOString();

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ················const·value·=⏎····················typeof·props.currentValue·===·'string' with ········const·value·=·typeof·props.currentValue·===·"string"
    Open

                    const value =

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ··········
    Open

                        props: {

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ··
    Open

        context.addRoute(crud.getRouterConfig());

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ········ru:·require('./locales/ru'), with ····ru:·require("./locales/ru")
    Open

            ru: require('./locales/ru'),

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ···················· with ··········
    Open

                        on: {

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ····
    Open

            },

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············ with ······
    Open

                render: (h, props) => {

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ························:·rootStore.getters['dashboard/timezone' with ··········:·rootStore.getters["dashboard/timezone"
    Open

                            : rootStore.getters['dashboard/timezone'] || moment.tz.guess();

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ···················· with ··········
    Open

                        props: {

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············required:·true, with ······required:·true
    Open

                required: true,

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············label:·'field.end_at' with ······label:·"field.end_at"
    Open

                label: 'field.end_at',

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ············
    Open

                            inputHandler: props.inputHandler,

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ········en:·require('./locales/en' with ····en:·require("./locales/en"
    Open

            en: require('./locales/en'),

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ····
    Open

            {

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ··············:·moment().startOf('day').tz(props.values.timezone,·true) with :·moment()⏎··············.startOf("day")⏎··············.tz(props.values.timezone,·true)⏎··············
    Open

                            : moment().startOf('day').tz(props.values.timezone, true).toISOString();

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ····························props.setValue('end_at' with ··············props.setValue("end_at"
    Open

                                props.setValue('end_at', value);

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ························timezone:·props.values.timezone, with ············timezone:·props.values.timezone
    Open

                            timezone: props.values.timezone,

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············label:·'field.start_at' with ······label:·"field.start_at"
    Open

                label: 'field.start_at',

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ···················· with ··········
    Open

                        on: {

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ··
    Open

        ];

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············required:·true, with ······required:·true
    Open

                required: true,

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············label:·'field.timezone' with ······label:·"field.timezone"
    Open

                label: 'field.timezone',

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ····························props.setValue('timezone' with ··············props.setValue("timezone"
    Open

                                props.setValue('timezone', value);

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ················const·value·=⏎····················typeof·props.currentValue·===·'string' with ········const·value·=·typeof·props.currentValue·===·"string"
    Open

                    const value =

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ········
    Open

                    return h(DatetimeInput, {

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ········ with ····
    Open

            {

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ··············:·moment().startOf('day').tz(props.values.timezone,·true).add(10,·'minutes') with :·moment()⏎··············.startOf("day")⏎··············.tz(props.values.timezone,·true)⏎··············.add(10,·"minutes")⏎··············
    Open

                            : moment().startOf('day').tz(props.values.timezone, true).add(10, 'minutes').toISOString();

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ························userID:·props.values.user_id, with ············userID:·props.values.user_id
    Open

                            userID: props.values.user_id,

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ········
    Open

                    return h(DatetimeInput, {

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ················props.setValue('timezone' with ········props.setValue("timezone"
    Open

                    props.setValue('timezone', timezone);

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ························ with ············
    Open

                            onTimezoneChange: value => {

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ··············?·moment(props.currentValue).tz(props.values.timezone,·true) with ?·moment(props.currentValue)⏎··············.tz(props.values.timezone,·true)⏎··············
    Open

                            ? moment(props.currentValue).tz(props.values.timezone, true).toISOString()

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ···················· with ··········
    Open

                        props: {

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ············
    Open

                            value,

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ··············
    Open

                            ? props.currentValue

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············ with ······
    Open

                render: (h, props) => {

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ············
    Open

                            inputHandler: props.inputHandler,

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ··············props.setValue('is_manual' with props.setValue("is_manual"
    Open

                                props.setValue('is_manual', true);

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············required:·true, with ······required:·true
    Open

                required: true,

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ········ with ····
    Open

            {

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ············
    Open

                            value,

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ··
    Open

        crud.new.addField(fieldsToFill);

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············ with ······
    Open

                },

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ················const·timezone·=⏎····················typeof·props.currentValue·===·'string' with ········const·timezone·=·typeof·props.currentValue·===·"string"
    Open

                    const timezone =

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ························value:·timezone, with ············value:·timezone
    Open

                            value: timezone,

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············key:·'start_at' with ······key:·"start_at"
    Open

                key: 'start_at',

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ················ with ········
    Open

                    });

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ···· with ··
    Open

        context.addLocalizationData({

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ························}, with ············}
    Open

                            },

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ············ with ······
    Open

                },

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ···················· with ··········
    Open

                        },

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ························}, with ············}
    Open

                            },

    For more information visit Source: http://eslint.org/docs/rules/

    Replace ····················}, with ··········}
    Open

                        },

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ··
    Open

        });

    For more information visit Source: http://eslint.org/docs/rules/

    Delete ··
    Open

        return context;

    For more information visit Source: http://eslint.org/docs/rules/

    There are no issues that match your filters.

    Category
    Status