Showing 1,813 of 3,998 total issues
exports
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
module.exports = class EventRepository {
constructor({
DonationPaymentEvent,
EmailRecipient,
MemberSubscribeEvent,
`` has 23 functions (exceeds 20 allowed). Consider refactoring. Open
User = ghostBookshelf.Model.extend({
tableName: 'users',
actionsCollectCRUD: true,
ActivityPubAPI
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
export class ActivityPubAPI {
constructor(
private readonly apiUrl: URL,
private readonly authApiUrl: URL,
private readonly handle: string,
Function buildObjectTypeHandlers
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
buildObjectTypeHandlers(objTypes, actType, context, permissionLoad) {
const objectTypeModelMap = {
post: models.Post,
role: models.Role,
user: models.User,
Function unsubscribeController
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = async function unsubscribeController(req, res) {
debug('unsubscribeController');
const {query} = url.parse(req.url, true);
File OffersIndex.tsx
has 269 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {Button, Tab, TabView} from '@tryghost/admin-x-design-system';
import {ButtonGroup, ButtonProps, showToast} from '@tryghost/admin-x-design-system';
import {Icon} from '@tryghost/admin-x-design-system';
import {Modal} from '@tryghost/admin-x-design-system';
import {SortMenu} from '@tryghost/admin-x-design-system';
File Users.tsx
has 269 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React, {useEffect, useState} from 'react';
import TopLevelGroup from '../../TopLevelGroup';
import clsx from 'clsx';
import useQueryParams from '../../../hooks/useQueryParams';
import useStaffUsers from '../../../hooks/useStaffUsers';
Function mockPosts
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function mockPosts(server) {
server.post('/posts', function ({posts, users, tags}) {
let attrs = this.normalizedRequestAttrs();
attrs.authors = extractAuthors(attrs, users);
Function getPortalPreviewUrl
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPortalPreviewUrl(overrides) {
let {
disableBackground = false,
page = 'signup',
button = this.settings.portalButton,
Function populateStripePricesFromStripePlansSetting
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
async populateStripePricesFromStripePlansSetting(options) {
if (!options) {
return this.models.Product.transaction((transacting) => {
return this.populateStripePricesFromStripePlansSetting({transacting});
});
Function connectAndSend
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports.connectAndSend = (socketAddress, message) => {
// Very basic guard against bad calls
if (!socketAddress || !socketAddress.host || !socketAddress.port || !logging || !logging.info || !logging.warn || !message) {
return Promise.resolve();
}
Function exports
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function (Bookshelf) {
const ParentModel = Bookshelf.Model;
Bookshelf.Model = Bookshelf.Model.extend({
/**
Function useLimiter
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const useLimiter = () => {
const {config} = useGlobalData();
const [LimitService, setLimitService] = useState<typeof import('@tryghost/limit-service') | null>(null);
useEffect(() => {
Function dummyCards
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
const dummyCards = (noOfCards: number) => {
const cards = [];
for (let i = 0; i < noOfCards; i++) {
cards.push(
File pages.js
has 268 lines of code (exceeds 250 allowed). Consider refactoring. Open
const models = require('../../models');
const tpl = require('@tryghost/tpl');
const errors = require('@tryghost/errors');
const getPostServiceInstance = require('../../services/posts/posts-service');
const ALLOWED_INCLUDES = ['tags', 'authors', 'authors.roles', 'tiers', 'count.signups', 'count.paid_conversions', 'post_revisions', 'post_revisions.author'];
Function chartData
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
get chartData() {
const totalCadence = this.dashboardStats.paidMembersByCadence.month + this.dashboardStats.paidMembersByCadence.year;
const monthlyPercentage = Math.round(this.dashboardStats.paidMembersByCadence.month / totalCadence * 100);
const annualPercentage = Math.round(this.dashboardStats.paidMembersByCadence.year / totalCadence * 100);
const barThickness = 5;
- 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 populateProductsAndPrices
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
async populateProductsAndPrices(options) {
if (!options) {
return this.models.Product.transaction((transacting) => {
return this.populateProductsAndPrices({transacting});
});
- 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 handleSetupEvent
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
async handleSetupEvent(session) {
const setupIntent = await this.api.getSetupIntent(session.setup_intent);
const memberRepository = this.deps.memberRepository;
const member = await memberRepository.get({
- 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 getCustomerIdByEmail
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
async getCustomerIdByEmail(email) {
await this._searchRateLimitBucket.throttle();
try {
const result = await this._stripe.customers.search({
query: `email:"${email}"`,
- 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 createCheckoutSession
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
async createCheckoutSession(req, res) {
const type = req.body.type ?? 'subscription';
const metadata = req.body.metadata ?? {};
const identity = req.body.identity;
const membersEnabled = true;
- 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"