Showing 1,820 of 4,015 total issues
Function formatRelativeTime
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
export function formatRelativeTime(dateString: string, t: TranslationFunction): string {
const date = new Date(dateString);
const now = new Date();
// Diff is in seconds
- 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 getAllActivities
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
async getAllActivities(
includeOwn: boolean = false,
includeReplies: boolean = false,
filter: {type?: string[]} | null = null
): Promise<Activity[]> {
- 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 formatUrl
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
export const formatUrl = (value: string, baseUrl?: string, nullable?: boolean) => {
if (nullable && !value) {
return {save: null, display: ''};
}
- 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 EditOfferModal.tsx
has 281 lines of code (exceeds 250 allowed). Consider refactoring. Open
import NiceModal from '@ebay/nice-modal-react';
import PortalFrame from '../../membership/portal/PortalFrame';
import toast from 'react-hot-toast';
import {Button, ConfirmationModal, Form, PreviewModalContent, TextArea, TextField, showToast} from '@tryghost/admin-x-design-system';
import {ErrorMessages, useForm, useHandleError} from '@tryghost/admin-x-framework/hooks';
Function generate
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
generate() {
const title = faker.lorem.sentence();
const content = faker.lorem.paragraphs(faker.datatype.number({
min: 3,
max: 10
Function getAdapter
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
getAdapter(adapterName, adapterClassName, config) {
if (!adapterName || !adapterClassName) {
throw new errors.IncorrectUsageError({
message: 'getAdapter must be called with a adapterName and a adapterClassName.'
});
Function countRelations
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
countRelations() {
return {
signups(modelOrCollection) {
modelOrCollection.query('columns', 'posts.*', (qb) => {
qb.count('members_created_events.id')
Function createSessionFromMagicLink
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
const createSessionFromMagicLink = async function createSessionFromMagicLink(req, res, next) {
if (!req.url.includes('token=')) {
return next();
}
File PreviewModal.tsx
has 280 lines of code (exceeds 250 allowed). Consider refactoring. Open
import NiceModal, {useModal} from '@ebay/nice-modal-react';
import clsx from 'clsx';
import React, {useEffect, useState} from 'react';
import useGlobalDirtyState from '../../hooks/useGlobalDirtyState';
import {confirmIfDirty} from '../../utils/modals';
File Form.tsx
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
import React from 'react';
import {Avatar} from '../Avatar';
import {Comment, useAppContext, useLabs} from '../../../AppContext';
import {ReactComponent as EditIcon} from '../../../images/icons/edit.svg';
import {Editor, EditorContent} from '@tiptap/react';
Function get
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = async function get(resource, options) {
options = options || {};
options.hash = options.hash || {};
options.data = options.data || {};
Function AddIntegrationModal
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
const AddIntegrationModal: React.FC<RoutingModalProps> = () => {
const modal = useModal();
const {updateRoute} = useRouting();
const [name, setName] = useState('');
const [errors, setErrors] = useState({name: ''});
OfferPage
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
export default class OfferPage extends React.Component {
static contextType = AppContext;
constructor(props, context) {
super(props, context);
SignupPage
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class SignupPage extends React.Component {
static contextType = AppContext;
constructor(props) {
super(props);
File members.js
has 277 lines of code (exceeds 250 allowed). Consider refactoring. Open
import moment from 'moment-timezone';
import nql from '@tryghost/nql';
import {Response} from 'miragejs';
import {
extractFilterParam,
Function up
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function up(knex) {
logging.info('Resolving the orphaned webhooks');
const orphanedWebhooks = await knex('webhooks')
.select('webhooks.id')
Function getDescription
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getDescription(data, root, options = {}) {
const context = root ? root.context : null;
let description = '';
Function NavigationModal
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
const NavigationModal = NiceModal.create(() => {
const modal = useModal();
const {updateRoute} = useRouting();
const {
localSettings,
Function getReferrerDetails
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
getReferrerDetails(history) {
// Empty history will return null as it means script is not loaded
if (history.length === 0) {
return {
referrerSource: null,
Function constructor
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor({
labs,
membersService,
donationService,
staffService,