Showing 1,820 of 4,015 total issues
Function ImageUpload
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
const ImageUpload: React.FC<ImageUploadProps> = ({
id,
children,
width = '100%',
height = '120px',
- 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 init
has 114 lines of code (exceeds 25 allowed). Consider refactoring. Open
async init() {
if (initialised) {
return;
}
File data-attributes.js
has 356 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable no-console */
import {getCheckoutSessionDataFromPlanAttribute, getUrlHistory} from './utils/helpers';
import {HumanReadableError, chooseBestErrorMessage} from './utils/errors';
import i18nLib from '@tryghost/i18n';
Function init
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
init() {
const config = require('../../../shared/config');
if (config.get('services:recommendations:enabled') === false) {
logging.info('[Recommendations] Service is disabled via config');
return;
Function doImport
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
doImport: async function doImport(importData, importOptions) {
debug('doImport');
importOptions = importOptions || {};
if (importOptions.importTag && importData?.data?.posts) {
Function exports
has 111 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = async (model, frame, options = {}) => {
const {tiers: tiersData} = options || {};
// NOTE: `model` is now overloaded and may be a bookshelf model or a POJO
let jsonModel = model;
Function beforeImport
has 111 lines of code (exceeds 25 allowed). Consider refactoring. Open
beforeImport() {
debug('beforeImport');
const activeTheme = _.find(this.dataToImport, {key: 'active_theme'});
Function foreach
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function foreach(items, options) {
if (!options) {
logging.warn(tpl(messages.iteratorNeeded));
}
- 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 updateProfile
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
async function updateProfile({data, state, api}) {
const {t} = state;
const [dataUpdate, emailUpdate] = await Promise.all([updateMemberData({data, state, api}), updateMemberEmail({data, state, api})]);
if (dataUpdate && emailUpdate) {
if (emailUpdate.success) {
- 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
exports
has 34 functions (exceeds 20 allowed). Consider refactoring. Open
module.exports = {
get all() {
return require('./all');
},
File settings.js
has 347 lines of code (exceeds 250 allowed). Consider refactoring. Open
const _ = require('lodash');
const crypto = require('crypto');
const keypair = require('keypair');
const ObjectID = require('bson-objectid').default;
const ghostBookshelf = require('./base');
Function setComplimentarySubscription
has 108 lines of code (exceeds 25 allowed). Consider refactoring. Open
async setComplimentarySubscription(data, options = {}) {
if (!options.transacting) {
return this._Member.transaction((transacting) => {
return this.setComplimentarySubscription(data, {
...options,
File validate.js
has 345 lines of code (exceeds 250 allowed). Consider refactoring. Open
const _ = require('lodash');
const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const _private = {};
let RESOURCE_CONFIG;
Function http
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
const http = (apiImpl) => {
/**
* @param {import('express').Request} req - Express request object.
* @param {import('express').Response} res - Express response object.
* @param {import('express').NextFunction} next - Express next function.
- 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 getPageFromLinkPath
has 106 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPageFromLinkPath(path) {
const customPricesSignupRegex = /^signup\/?(?:\/(\w+?))?\/?$/;
const customMonthlyProductSignup = /^signup\/?(?:\/(\w+?))\/monthly\/?$/;
const customYearlyProductSignup = /^signup\/?(?:\/(\w+?))\/yearly\/?$/;
const customOfferRegex = /^offers\/(\w+?)\/?$/;
File members-api.js
has 342 lines of code (exceeds 250 allowed). Consider refactoring. Open
const {Router} = require('express');
const body = require('body-parser');
const MagicLink = require('@tryghost/magic-link');
const errors = require('@tryghost/errors');
const logging = require('@tryghost/logging');
Function permissible
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
permissible: async function permissible(userModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
const self = this;
const userModel = userModelOrId;
let origArgs;
File TierDetailModal.tsx
has 341 lines of code (exceeds 250 allowed). Consider refactoring. Open
import NiceModal from '@ebay/nice-modal-react';
import React, {useEffect, useRef} from 'react';
import TierDetailPreview from './TierDetailPreview';
import useSettingGroup from '../../../../hooks/useSettingGroup';
import {Button, ButtonProps, ConfirmationModal, CurrencyField, Form, Heading, Icon, Modal, Select, SortableList, TextField, Toggle, URLTextField, showToast, useSortableIndexedList} from '@tryghost/admin-x-design-system';
File post.js
has 339 lines of code (exceeds 250 allowed). Consider refactoring. Open
import Ember from 'ember';
import Model, {attr, belongsTo, hasMany} from '@ember-data/model';
import ValidationEngine from 'ghost-admin/mixins/validation-engine';
import boundOneWay from 'ghost-admin/utils/bound-one-way';
import moment from 'moment-timezone';
File actions.ts
has 339 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {AddComment, Comment, CommentsOptions, EditableAppContext} from './AppContext';
import {AdminApi} from './utils/adminApi';
import {GhostApi} from './utils/api';
import {Page} from './pages';