wikimedia/mediawiki-core

View on GitHub
resources/lib/pinia/pinia.iife.js

Summary

Maintainability
F
1 mo
Test Coverage

Function Pinia has a Cognitive Complexity of 464 (exceeds 5 allowed). Consider refactoring.
Open

var Pinia = (function (exports, vueDemi) {
  'use strict';

  /**
   * setActivePinia must be called to handle SSR at the top of functions like
Severity: Minor
Found in resources/lib/pinia/pinia.iife.js - About 1 wk 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 Pinia has 1684 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Pinia = (function (exports, vueDemi) {
  'use strict';

  /**
   * setActivePinia must be called to handle SSR at the top of functions like
Severity: Major
Found in resources/lib/pinia/pinia.iife.js - About 1 wk to fix

    File pinia.iife.js has 1687 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*!
      * pinia v2.0.16
      * (c) 2022 Eduardo San Martin Morote
      * @license MIT
      */
    Severity: Major
    Found in resources/lib/pinia/pinia.iife.js - About 4 days to fix

      Function createSetupStore has 351 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
            let scope;
            const optionsForPlugin = assign({ actions: {} }, options);
            /* istanbul ignore if */
            // @ts-expect-error: active is an internal property
      Severity: Major
      Found in resources/lib/pinia/pinia.iife.js - About 1 day to fix

        Function addStoreToDevtools has 168 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          function addStoreToDevtools(app, store) {
              if (!componentStateTypes.includes(getStoreType(store.$id))) {
                  componentStateTypes.push(getStoreType(store.$id));
              }
              setupDevtoolsPlugin({
        Severity: Major
        Found in resources/lib/pinia/pinia.iife.js - About 6 hrs to fix

          Function registerPiniaDevtools has 168 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function registerPiniaDevtools(app, pinia) {
                setupDevtoolsPlugin({
                    id: 'dev.esm.pinia',
                    label: 'Pinia 🍍',
                    logo: 'https://pinia.vuejs.org/logo.svg',
          Severity: Major
          Found in resources/lib/pinia/pinia.iife.js - About 6 hrs to fix

            Function constructor has 90 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  constructor(plugin, hook) {
                      this.target = null;
                      this.targetQueue = [];
                      this.onQueue = [];
                      this.plugin = plugin;
            Severity: Major
            Found in resources/lib/pinia/pinia.iife.js - About 3 hrs to fix

              Function defineStore has 58 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function defineStore(
                // TODO: add proper types from above
                idOrOptions, setup, setupOptions) {
                    let id;
                    let options;
              Severity: Major
              Found in resources/lib/pinia/pinia.iife.js - About 2 hrs to fix

                Function _hotUpdate has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                          store._hotUpdate = vueDemi.markRaw((newStore) => {
                              store._hotUpdating = true;
                              newStore._hmrPayload.state.forEach((stateKey) => {
                                  if (stateKey in store.$state) {
                                      const newStateTarget = newStore.$state[stateKey];
                Severity: Major
                Found in resources/lib/pinia/pinia.iife.js - About 2 hrs to fix

                  Function formatStoreForInspectorState has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    function formatStoreForInspectorState(store) {
                        if (isPinia(store)) {
                            const storeNames = Array.from(store._s.keys());
                            const storeMap = store._s;
                            const state = {
                  Severity: Minor
                  Found in resources/lib/pinia/pinia.iife.js - About 1 hr to fix

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

                          function useStore(pinia, hot) {
                              const currentInstance = vueDemi.getCurrentInstance();
                              pinia =
                                  // in test mode, ignore the argument provided as we can always retrieve a
                                  // pinia instance with getActivePinia()
                    Severity: Minor
                    Found in resources/lib/pinia/pinia.iife.js - About 1 hr to fix

                      Function fileSaverSaveAs has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        function fileSaverSaveAs(blob, name, opts, popup) {
                            // Open a popup immediately do go around popup blocker
                            // Mostly only available on user interaction and the fileReader is async so...
                            popup = popup || open('', '_blank');
                            if (popup) {
                      Severity: Minor
                      Found in resources/lib/pinia/pinia.iife.js - About 1 hr to fix

                        Function wrapAction has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              function wrapAction(name, action) {
                                  return function () {
                                      setActivePinia(pinia);
                                      const args = Array.from(arguments);
                                      const afterCallbackList = [];
                        Severity: Minor
                        Found in resources/lib/pinia/pinia.iife.js - About 1 hr to fix

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

                            function createOptionsStore(id, options, pinia, hot) {
                                const { state, actions, getters } = options;
                                const initialState = pinia.state.value[id];
                                let store;
                                function setup() {
                          Severity: Minor
                          Found in resources/lib/pinia/pinia.iife.js - About 1 hr to fix

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

                              function createPinia() {
                                  const scope = vueDemi.effectScope(true);
                                  // NOTE: here we could check the window object for a state and directly set it
                                  // if there is anything like it with Vue 3 SSR
                                  const state = scope.run(() => vueDemi.ref({}));
                            Severity: Minor
                            Found in resources/lib/pinia/pinia.iife.js - About 1 hr to fix

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

                                const PiniaVuePlugin = function (_Vue) {
                                    // Equivalent of
                                    // app.config.globalProperties.$pinia = pinia
                                    _Vue.mixin({
                                        beforeCreate() {
                              Severity: Minor
                              Found in resources/lib/pinia/pinia.iife.js - About 1 hr to fix

                                Function $patch has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                      function $patch(partialStateOrMutator) {
                                          let subscriptionMutation;
                                          isListening = isSyncListening = false;
                                          // reset the debugger events since patches are sync
                                          /* istanbul ignore else */
                                Severity: Minor
                                Found in resources/lib/pinia/pinia.iife.js - About 1 hr to fix

                                  Function get has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                                get: (_target, prop) => {
                                                    if (this.target) {
                                                        return this.target[prop];
                                                    }
                                                    else if (prop === 'on') {
                                  Severity: Minor
                                  Found in resources/lib/pinia/pinia.iife.js - About 1 hr to fix

                                    Function downloadSaveAs has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      function downloadSaveAs(blob, name = 'download', opts) {
                                          const a = document.createElement('a');
                                          a.download = name;
                                          a.rel = 'noopener'; // tabnabbing
                                          // TODO: detect chrome extensions & packaged apps
                                    Severity: Minor
                                    Found in resources/lib/pinia/pinia.iife.js - About 1 hr to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                            if (vueDemi.isRef(prop)) {
                                                                prop.value = initialState[key];
                                                            }
                                                            else {
                                                                // probably a reactive object, lets recursively assign
                                      Severity: Major
                                      Found in resources/lib/pinia/pinia.iife.js - About 45 mins to fix

                                        Function createSetupStore has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                          function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
                                        Severity: Minor
                                        Found in resources/lib/pinia/pinia.iife.js - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                            if (IS_CLIENT) {
                                                                const getters = 
                                                                // @ts-expect-error: it should be on the store
                                                                setupStore._getters || (setupStore._getters = vueDemi.markRaw([]));
                                                                getters.push(key);
                                          Severity: Major
                                          Found in resources/lib/pinia/pinia.iife.js - About 45 mins to fix

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

                                                          Object.keys(store._hmrPayload.getters).forEach((key) => {
                                                              if (!(key in newStore._hmrPayload.getters)) {
                                                                  vueDemi.del(store, key);
                                                              }
                                                          });
                                            Severity: Major
                                            Found in resources/lib/pinia/pinia.iife.js and 1 other location - About 1 hr to fix
                                            resources/lib/pinia/pinia.iife.js on lines 1717..1721

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

                                            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

                                                          Object.keys(store._hmrPayload.actions).forEach((key) => {
                                                              if (!(key in newStore._hmrPayload.actions)) {
                                                                  vueDemi.del(store, key);
                                                              }
                                                          });
                                            Severity: Major
                                            Found in resources/lib/pinia/pinia.iife.js and 1 other location - About 1 hr to fix
                                            resources/lib/pinia/pinia.iife.js on lines 1711..1715

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

                                            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

                                                              {
                                                                  icon: 'content_paste',
                                                                  action: async () => {
                                                                      await actionGlobalPasteState(pinia);
                                                                      api.sendInspectorTree(INSPECTOR_ID);
                                            Severity: Minor
                                            Found in resources/lib/pinia/pinia.iife.js and 1 other location - About 55 mins to fix
                                            resources/lib/pinia/pinia.iife.js on lines 711..719

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

                                            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

                                                              {
                                                                  icon: 'folder_open',
                                                                  action: async () => {
                                                                      await actionGlobalOpenStateFile(pinia);
                                                                      api.sendInspectorTree(INSPECTOR_ID);
                                            Severity: Minor
                                            Found in resources/lib/pinia/pinia.iife.js and 1 other location - About 55 mins to fix
                                            resources/lib/pinia/pinia.iife.js on lines 695..703

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

                                            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

                                            There are no issues that match your filters.

                                            Category
                                            Status