Showing 1,734 of 3,834 total issues
File MemberRepository.js
has 1289 lines of code (exceeds 250 allowed). Consider refactoring. Open
const _ = require('lodash');
const errors = require('@tryghost/errors');
const logging = require('@tryghost/logging');
const tpl = require('@tryghost/tpl');
const DomainEvents = require('@tryghost/domain-events');
File post.js
has 1168 lines of code (exceeds 250 allowed). Consider refactoring. Open
// # Post Model
const _ = require('lodash');
const uuid = require('uuid');
const moment = require('moment');
const {sequence} = require('@tryghost/promise');
Function linkSubscription
has a Cognitive Complexity of 132 (exceeds 5 allowed). Consider refactoring. Open
async linkSubscription(data, options = {}) {
if (!this._stripeAPIService.configured) {
throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'link Stripe Subscription'})});
}
- 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
File schema.js
has 1056 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* String Column Sizes Information
* (From: https://github.com/TryGhost/Ghost/pull/7932)
*
* Small strings = length 50
* Medium strings = length 191
File Frame.styles.js
has 1051 lines of code (exceeds 250 allowed). Consider refactoring. Open
/** By default, CRAs webpack bundle combines and appends the main css at root level, so they are not applied inside iframe
* This uses a hack where we append `<style> </style>` tag with all CSS inside the head of iframe dynamically, thus making it available easily
* We can create separate variables to keep styles grouped logically, and export them as one appended string
*/
File ProductsSection.js
has 976 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React, {useContext, useEffect, useState} from 'react';
import {ReactComponent as LoaderIcon} from '../../images/icons/loader.svg';
import {ReactComponent as CheckmarkIcon} from '../../images/icons/checkmark.svg';
import {getCurrencySymbol, getPriceString, getStripeAmount, getMemberActivePrice, getProductFromPrice, getFreeTierTitle, getFreeTierDescription, getFreeProduct, getFreeProductBenefits, getSupportAddress, formatNumber, isCookiesDisabled, hasOnlyFreeProduct, isMemberActivePrice, hasFreeTrialTier, isComplimentaryMember} from '../../utils/helpers';
import AppContext from '../../AppContext';
Function onSaving
has a Cognitive Complexity of 112 (exceeds 5 allowed). Consider refactoring. Open
onSaving: async function onSaving(model, attrs, options) {
options = options || {};
const self = this;
let title;
- 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 ProductsSectionStyles
has 436 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const ProductsSectionStyles = () => {
// const products = getSiteProducts({site});
// const noOfProducts = products.length;
return `
.gh-portal-products {
File App.js
has 821 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React from 'react';
import * as Sentry from '@sentry/react';
import TriggerButton from './components/TriggerButton';
import Notification from './components/Notification';
import PopupModal from './components/PopupModal';
File user.js
has 804 lines of code (exceeds 250 allowed). Consider refactoring. Open
const _ = require('lodash');
const validator = require('@tryghost/validator');
const ObjectId = require('bson-objectid').default;
const ghostBookshelf = require('./base');
const baseUtils = require('./base/utils');
File helpers.js
has 792 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {getDateString} from './date-time';
export function removePortalLinkFromUrl() {
const [path] = window.location.hash.substr(1).split('?');
const linkRegex = /^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/;
Function emptyData
has 368 lines of code (exceeds 25 allowed). Consider refactoring. Open
get emptyData() {
return {
stats: [
{
date: '2022-04-07',
File anchor-attribution.js
has 740 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* global Chart */
import Component from '@glimmer/component';
import moment from 'moment-timezone';
import {action} from '@ember/object';
File SignupPage.js
has 717 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React from 'react';
import ActionButton from '../common/ActionButton';
import AppContext from '../../AppContext';
import CloseButton from '../common/CloseButton';
import SiteTitleBackButton from '../common/SiteTitleBackButton';
Function exports
has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function (Bookshelf) {
Bookshelf.Model = Bookshelf.Model.extend({
initializeEvents: function () {
// NOTE: triggered before `creating`/`updating`
this.on('saving', function onSaving(newObj, attrs, options) {
- 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 linkSubscription
has 325 lines of code (exceeds 25 allowed). Consider refactoring. Open
async linkSubscription(data, options = {}) {
if (!this._stripeAPIService.configured) {
throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'link Stripe Subscription'})});
}
Function SUBSCRIBED_FILTER
has a Cognitive Complexity of 81 (exceeds 5 allowed). Consider refactoring. Open
export const SUBSCRIBED_FILTER = ({newsletters, feature, group}) => {
if (feature.filterEmailDisabled) {
return {
label: newsletters.length > 1 ? 'All newsletters' : 'Newsletter subscription',
name: 'subscribed',
- 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 onSaving
has 318 lines of code (exceeds 25 allowed). Consider refactoring. Open
onSaving: async function onSaving(model, attrs, options) {
options = options || {};
const self = this;
let title;
Function AddOfferModal
has 313 lines of code (exceeds 25 allowed). Consider refactoring. Open
const AddOfferModal = () => {
const {siteData} = useGlobalData();
const typeOptions = [
{title: 'Discount', description: 'Offer a special reduced price', value: 'percent'},
{title: 'Free trial', description: 'Give free access for a limited time', value: 'trial'}
File EventRepository.js
has 684 lines of code (exceeds 250 allowed). Consider refactoring. Open
const errors = require('@tryghost/errors');
const nql = require('@tryghost/nql');
const mingo = require('mingo');
const {replaceFilters, expandFilters, splitFilter, getUsedKeys, chainTransformers, mapKeys} = require('@tryghost/mongo-utils');