Showing 1,820 of 4,015 total issues
File api.js
has 544 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {HumanReadableError} from './errors';
import {transformApiSiteData, transformApiTiersData, getUrlHistory} from './helpers';
function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) {
const apiPath = 'members/api';
File actions.js
has 542 lines of code (exceeds 250 allowed). Consider refactoring. Open
import setupGhostApi from './utils/api';
import {chooseBestErrorMessage} from './utils/errors';
import {createPopupNotification, getMemberEmail, getMemberName, getProductCadenceFromPrice, removePortalLinkFromUrl, getRefDomain} from './utils/helpers';
function switchPage({data, state}) {
File StripeMigrations.js
has 528 lines of code (exceeds 250 allowed). Consider refactoring. Open
const _ = require('lodash');
const logging = require('@tryghost/logging');
module.exports = class StripeMigrations {
/**
Function mockMembers
has 216 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function mockMembers(server) {
server.post('/members/', withPermissionsCheck(ALLOWED_ROLES, function ({members}) {
const attrs = this.normalizedRequestAttrs();
return members.create(attrs);
}));
File CollectionsService.ts
has 516 lines of code (exceeds 250 allowed). Consider refactoring. Open
import logging from '@tryghost/logging';
import tpl from '@tryghost/tpl';
import isEqual from 'lodash/isEqual';
import {Knex} from 'knex';
import {
Function update
has 209 lines of code (exceeds 25 allowed). Consider refactoring. Open
async update(data, options) {
const sharedOptions = {
transacting: options.transacting
};
Function draw
has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring. Open
Chart.elements.Rectangle.prototype.draw = function () {
var ctx = this._chart.ctx;
var vm = this._view;
var left, right, top, bottom, borderSkipped, radius;
- 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 handleVideoPlayer
has 197 lines of code (exceeds 25 allowed). Consider refactoring. Open
const handleVideoPlayer = function (videoElementContainer) {
const videoPlayer = videoElementContainer.querySelector('.kg-video-player');
const videoPlayerContainer = videoElementContainer.querySelector('.kg-video-player-container');
const playIconContainer = videoElementContainer.querySelector('.kg-video-play-icon');
const pauseIconContainer = videoElementContainer.querySelector('.kg-video-pause-icon');
Function UnsubscribePage
has 197 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function UnsubscribePage() {
const {site, api, pageData, member: loggedInMember, onAction, t} = useContext(AppContext);
// member is the member data fetched from the API based on the uuid and its state is limited to just this modal, not all of Portal
const [member, setMember] = useState();
const [loading, setLoading] = useState(true);
Function InviteUserModal
has 194 lines of code (exceeds 25 allowed). Consider refactoring. Open
const InviteUserModal = NiceModal.create(() => {
const modal = NiceModal.useModal();
const rolesQuery = useBrowseRoles();
const assignableRolesQuery = useBrowseRoles({
searchParams: {limit: 'all', permissions: 'assign'}
Function milestoneEmailConfig
has 192 lines of code (exceeds 25 allowed). Consider refactoring. Open
const milestoneEmailConfig = (siteTitle, formattedValue) => {
const arrContent = {
subject: `${siteTitle} hit ${formattedValue} ARR`,
heading: `Congrats! You reached ${formattedValue} ARR`,
content: [
File ProductRepository.js
has 486 lines of code (exceeds 250 allowed). Consider refactoring. Open
const {UpdateCollisionError, NotFoundError, MethodNotAllowedError, ValidationError, BadRequestError} = require('@tryghost/errors');
const tpl = require('@tryghost/tpl');
const messages = {
priceMustBeInteger: 'Tier prices must be an integer.',
File members.js
has 476 lines of code (exceeds 250 allowed). Consider refactoring. Open
// NOTE: We must not cache references to membersService.api
// as it is a getter and may change during runtime.
const moment = require('moment-timezone');
const errors = require('@tryghost/errors');
const logging = require('@tryghost/logging');
File gh-post-settings-menu.js
has 472 lines of code (exceeds 250 allowed). Consider refactoring. Open
import Component from '@ember/component';
import boundOneWay from 'ghost-admin/utils/bound-one-way';
import classic from 'ember-classic-decorator';
import moment from 'moment-timezone';
import {action, computed} from '@ember/object';
Function OffersIndexModal
has 182 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const OffersIndexModal = () => {
const modal = useModal();
const {updateRoute} = useRouting();
const {data: {offers: allOffers = []} = {}, isFetching: isFetchingOffers} = useBrowseOffers({
searchParams: {
Function exports
has a Cognitive Complexity of 47 (exceeds 5 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;
- 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 StripeAPI.js
has 462 lines of code (exceeds 250 allowed). Consider refactoring. Open
// @ts-ignore
const {VersionMismatchError} = require('@tryghost/errors');
// @ts-ignore
const debug = require('@tryghost/debug')('stripe');
const Stripe = require('stripe').Stripe;
Function exports
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function (Bookshelf) {
const insertAction = (data, options) => {
// CASE: model does not support action for target event
if (!data) {
return;
- 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 AddDetailsPopup
has 177 lines of code (exceeds 25 allowed). Consider refactoring. Open
const AddDetailsPopup = (props: Props) => {
const inputNameRef = useRef<HTMLInputElement>(null);
const inputExpertiseRef = useRef<HTMLInputElement>(null);
const {dispatchAction, member, accentColor, t} = useAppContext();
File RouterController.js
has 461 lines of code (exceeds 250 allowed). Consider refactoring. Open
const tpl = require('@tryghost/tpl');
const logging = require('@tryghost/logging');
const _ = require('lodash');
const {BadRequestError, NoPermissionError, UnauthorizedError, DisabledFeatureError} = require('@tryghost/errors');
const errors = require('@tryghost/errors');