Opetushallitus/eperusteet-frontend-utils

View on GitHub

Showing 71 of 183 total issues

Function open has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        async open() {
          if (!this.view.editable) {
            return;
          }

Severity: Major
Found in vue/src/components/EpContent/ImageExtension.ts - About 2 hrs to fix

    Function view has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

      get view() {
        const handler = this.handler;
        return Vue.extend({
          components: {
            TermiEditor,
    Severity: Minor
    Found in vue/src/components/EpContent/TermiExtension.ts - 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 rakenneNodecolor has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    export function rakenneNodecolor(node, parentMandatory, el) {
      const isRyhma = !!node.rooli;
    
      if (isRyhma) {
        const mapped = RooliToTheme[node.rooli];
    Severity: Minor
    Found in vue/src/utils/perusterakenne.ts - 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 start has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public async start() {
        this.state.disabled = true;
        this.state.isLoading = true;
    
        // Ei editointia uudestaan
    Severity: Minor
    Found in vue/src/components/EpEditointi/EditointiStore.ts - About 1 hr to fix

      Function view has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        get view() {
          const linkkiHandler = this.linkkiHandler;
          return Vue.extend({
            components: {
            },
      Severity: Minor
      Found in vue/src/components/EpContent/CustomLink.ts - About 1 hr to fix

        Function createRestangular has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            export const createRestangular = (
                scope,
                field: string,
                resolvedObj: Restangular.IElement,
                callbacks: IEditointikontrollitCallbacks = {}) => {
        Severity: Minor
        Found in components/editointikontrollit/editointikontrollit.ts - 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 install has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public install(vue: typeof Vue) {
            function aikaleimaFnFactory(this: void, format: string) {
              const self: any = this;
              return function(this: void, value: number) {
                if (!Kielet.i18n.locale) {
        Severity: Minor
        Found in vue/src/plugins/aikaleima.ts - About 1 hr to fix

          Function controller has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              export const controller = ($scope, $rootScope, $timeout) => {
                  $scope.toggleHistoryModal = () => {
                      if ($scope.$$showingHistoryModal) {
                          HistoryModal.hide();
                      }
          Severity: Minor
          Found in components/editointikontrollit/editointikontrollit.ts - About 1 hr to fix

            Function install has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              public static install(vue: typeof Vue) {
                if (!vue.prototype.$notify) {
                  throw new Error('Vue.use(require("vue-notification"))');
                }
            
            
            Severity: Minor
            Found in vue/src/plugins/notifikaatiot.ts - About 1 hr to fix

              Function resolveRouterMetaProps has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function resolveRouterMetaProps(to) {
                let props = {};
              
                try {
                  for (const record of to.matched) {
              Severity: Minor
              Found in vue/src/utils/router.ts - About 1 hr to fix

                Function setPerusteData has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                export function setPerusteData(node: NavigationNode, rawNode: NavigationNodeDto) {
                  switch (rawNode.type as string) {
                  case 'viite':
                  case 'taiteenala':
                  case 'liite':
                Severity: Minor
                Found in vue/src/utils/NavigationBuilder.ts - 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 dateformatvalidator has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    export const dateformatvalidator = () => {
                
                        return {
                            restrict: "A",
                            require: "ngModel",
                Severity: Minor
                Found in components/datepicker/datepicker.ts - About 1 hr to fix

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

                    public kaanna(value?: LokalisoituTeksti | undefined | null, emptyWhenNotFound = false, squareBrackets = true, forcedLang = null): string {
                      if (!value) {
                        return '';
                      }
                      else if (_.isObject(value)) {
                  Severity: Minor
                  Found in vue/src/stores/kieli.ts - About 1 hr to fix

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

                                link: (scope, element, attrs) => {
                    
                                    scope.type = scope.type || "text";
                                    attrs.$observe("required", (value) => {
                                        if (value === "required" || value === "true" || value === "") {
                    Severity: Minor
                    Found in components/datepicker/datepicker.ts - About 1 hr to fix

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

                                      function setup() {
                                          element.find(TERMI_MATCHER).each(function () {
                                              var jqEl: any = angular.element(this);
                                              var viiteId: any = jqEl.attr('data-viite');
                                              TermistoData.getByAvain(viiteId, $stateParams.ktId).then(function(res) {
                      Severity: Minor
                      Found in components/termisto/termisto.ts - About 1 hr to fix

                        Function mockEditointiStore has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function mockEditointiStore<T>(config: Partial<IEditoitava> = {}) {
                          const editointi = {
                            acquire: jest.fn(async () => {
                              const vanhentuu = new Date();
                              vanhentuu.setMinutes(vanhentuu.getMinutes() + 10);
                        Severity: Minor
                        Found in vue/src/utils/jestutils.ts - About 1 hr to fix

                          Function dateformatvalidator has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                          Open

                              export const dateformatvalidator = () => {
                          
                                  return {
                                      restrict: "A",
                                      require: "ngModel",
                          Severity: Minor
                          Found in components/datepicker/datepicker.ts - 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 getLaajaAlaisetKoodit has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export function getLaajaAlaisetKoodit() {
                            return [{
                              koodi: 'lops2019laajaalainenosaaminen_1',
                              nimi: {
                                fi: 'Globaali- ja kulttuuriosaaminen',
                          Severity: Minor
                          Found in vue/src/utils/perusteet.ts - About 1 hr to fix

                            Function start has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                        start: () => _$q((resolve, reject) => {
                                            const editoi = (osa) => {
                                                _.assign(resolvedObj, osa);
                                                backup = _.cloneDeep(resolvedObj);
                                                scope[field] = _.clone(resolvedObj);
                            Severity: Minor
                            Found in components/editointikontrollit/editointikontrollit.ts - About 1 hr to fix

                              Function link has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      link: (scope, el, attrs) => {
                                          const kaannaValue = (value) => _.isObject(value)
                                              ? KaannaService.kaannaSisalto(value)
                                              : KaannaService.kaanna(value);
                                          const original = getAttr(attrs["kaanna"], scope) || el.text();
                              Severity: Minor
                              Found in components/lokalisointi/kaanna.ts - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language