Showing 1,756 of 3,886 total issues
File SettingsBREADService.js
has 285 lines of code (exceeds 250 allowed). Consider refactoring. Open
const _ = require('lodash');
const tpl = require('@tryghost/tpl');
const {NotFoundError, NoPermissionError, BadRequestError, IncorrectUsageError, ValidationError} = require('@tryghost/errors');
const {obfuscatedSetting, isSecretSetting, hideValueIfSecret} = require('./settings-utils');
const logging = require('@tryghost/logging');
Function AmpModal
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
const AmpModal = NiceModal.create(() => {
const {updateRoute} = useRouting();
const {settings} = useGlobalData();
const [ampEnabled] = getSettingValues<boolean>(settings, ['amp']);
const [ampId] = getSettingValues<string>(settings, ['amp_gtag_id']);
Function useFetchApi
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const useFetchApi = () => {
const {ghostVersion, sentryDSN} = useFramework();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return async <ResponseData = any>(endpoint: string | URL, {headers = {}, retry, ...options}: RequestOptions = {}): Promise<ResponseData> => {
Offer
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class Offer {
events = [];
get id() {
return this.props.id.toHexString();
}
Member
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
const Member = ghostBookshelf.Model.extend({
tableName: 'members',
defaults() {
return {
I18n
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class I18n {
/**
* @param {object} [options]
* @param {string} options.basePath - the base path to the translations directory
* @param {string} [options.locale] - a locale string
Function edit
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
async edit(settings, options, stripeConnectData) {
let filteredSettings = settings.filter((setting) => {
// The `stripe_connect_integration_token` "setting" is only used to set the `stripe_connect_*` settings.
return ![
'stripe_connect_integration_token',
File authors.js
has 283 lines of code (exceeds 250 allowed). Consider refactoring. Open
const _ = require('lodash');
const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const {sequence} = require('@tryghost/promise');
Function mockStats
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function mockStats(server) {
server.get('/stats/subscriptions/', function () {
return {
stats: [],
meta: {
Function setupMembersApp
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function setupMembersApp() {
debug('Members App setup start');
const membersApp = express('members');
// Members API shouldn't be cached
Function each
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
_.each(columns, function each(columnKey) {
let message = ''; // KEEP: Validator.js only validates strings.
const strVal = _.toString(model.get(columnKey));
if (options.method !== 'insert' && !_.has(model.changed, columnKey)) {
Function up
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function up(knex) {
logging.info('Checking default_content_visibility for specific tiers');
const settings = await knex('settings')
.select()
Function replaceIdentifiers
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
replaceIdentifiers() {
const ownerUserId = _.find(this.requiredExistingData.users, (user) => {
if (user.roles[0].name === 'Owner') {
return true;
}
Function getImageDimensions
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function getImageDimensions(metaData) {
const MAX_SOCIAL_IMG_WIDTH = config.get('imageOptimization:internalImageSizes:social-image:width') || 1200;
const fetch = {
coverImage: imageSizeCache.getCachedImageSizeFromUrl(metaData.coverImage.url),
Function add
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
async add(data, options) {
if (!this.stripeService.configured && (data.comped || data.stripe_customer_id)) {
const property = data.comped ? 'comped' : 'stripe_customer_id';
throw new errors.ValidationError({
message: tpl(messages.stripeNotConnected),
- 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 mediaValidation
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
const mediaValidation = function ({type}) {
return function mediaUploadValidation(req, res, next) {
const extensions = (config.get('uploads')[type] && config.get('uploads')[type].extensions) || [];
const contentTypes = (config.get('uploads')[type] && config.get('uploads')[type].contentTypes) || [];
- 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 render
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
render() {
const {page, pageQuery, site, customSiteUrl} = this.context;
const products = getSiteProducts({site});
const noOfProducts = products.length;
- 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 NotificationText
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
const NotificationText = ({type, status, context}) => {
const t = context.t;
const signinPortalLink = getPortalLink({page: 'signin', siteUrl: context.site.url});
const singupPortalLink = getPortalLink({page: 'signup', siteUrl: context.site.url});
- 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 getPortalPreviewUrl
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
export const getPortalPreviewUrl = ({settings, config, tiers, siteData, selectedTab} : portalPreviewUrlTypes): string | null => {
if (!siteData?.url) {
return null;
}
let portalTiers = tiers.filter((t) => {
- 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 ThemePreview
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
}> = ({
selectedTheme,
isInstalling,
installedTheme,
onBack,
- 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"