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
- Read upRead up
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
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
*/
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
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({
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',
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;
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;
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];
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 = {
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()
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) {
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 = [];
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() {
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({}));
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() {
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 */
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') {
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
Avoid deeply nested control flow statements. Open
if (vueDemi.isRef(prop)) {
prop.value = initialState[key];
}
else {
// probably a reactive object, lets recursively assign
Function createSetupStore
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
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);
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);
}
});
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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);
}
});
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
{
icon: 'content_paste',
action: async () => {
await actionGlobalPasteState(pinia);
api.sendInspectorTree(INSPECTOR_ID);
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
{
icon: 'folder_open',
action: async () => {
await actionGlobalOpenStateFile(pinia);
api.sendInspectorTree(INSPECTOR_ID);
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76