TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function setupAdminApp has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function setupAdminApp() {
    debug('Admin setup start');
    const adminApp = express('admin');

    // Admin assets
Severity: Minor
Found in ghost/core/core/server/web/admin/app.js - About 1 hr to fix

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 up has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    async function up(knex) {
        // This uses the default settings from core/server/data/schema/default-settings/default-settings.json
        const newsletter = {
            id: (new ObjectId()).toHexString(),
            uuid: crypto.randomUUID(),

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 dropForeign has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

async function dropForeign({fromTable, fromColumn, toTable, toColumn, constraintName, transaction = db.knex}) {
    if (DatabaseInfo.isSQLite(transaction)) {
        const foreignKeyExists = await hasForeignSQLite({fromTable, fromColumn, toTable, toColumn, transaction});
        if (!foreignKeyExists) {
            logging.warn(`Skipped dropping foreign key from ${fromTable}.${fromColumn} to ${toTable}.${toColumn} - does not exist`);
Severity: Minor
Found in ghost/core/core/server/data/schema/commands.js - About 1 hr to fix

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 addFixturesForModel has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    async addFixturesForModel(modelFixture, options = {}) {
        // Clone the fixtures as they get changed in this function.
        // The initial blog posts will be added a `published_at` property, which
        // would change the fixturesHash.
        modelFixture = _.cloneDeep(modelFixture);
Severity: Minor
Found in ghost/core/core/server/data/schema/fixtures/FixtureManager.js - About 1 hr to fix

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 SessionFromToken has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function SessionFromToken({
    getTokenFromRequest,
    getLookupFromToken,
    findUserByLookup,
    createSession,
Severity: Minor
Found in ghost/mw-session-from-token/lib/session-from-token.js - About 1 hr to fix

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 channelController has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function channelController(req, res, next) {
    debug('channelController', req.params, res.routerOptions);

    const pathOptions = {
        page: req.params.page !== undefined ? req.params.page : 1,
Severity: Minor
Found in ghost/core/core/frontend/services/routing/controllers/channel.js - About 1 hr to fix

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 formSubmitHandler has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export function formSubmitHandler({event, form, errorEl, siteUrl, submitHandler}, 
    t = (str) => {
        return str;
    }) {
    form.removeEventListener('submit', submitHandler);
Severity: Minor
Found in apps/portal/src/data-attributes.js - About 1 hr to fix

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 usePinturaEditor has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export default function usePinturaEditor() {
    const {config: globalConfig, settings} = useGlobalData() as { config: Config, settings: Setting[] };
    const [pintura] = getSettingValues<boolean>(settings, ['pintura']);
    const [scriptLoaded, setScriptLoaded] = useState<boolean>(false);
    const [cssLoaded, setCssLoaded] = useState<boolean>(false);
Severity: Minor
Found in apps/admin-x-settings/src/hooks/usePinturaEditor.ts - About 1 hr to fix

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 getOfferLabel has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

function getOfferLabel({offer, price, subscriptionStartDate, t}) {
    let offerLabel = '';

    if (offer?.type === 'trial') {
        return '';

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 useDefaultRecipientsOptions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const useDefaultRecipientsOptions = (selectedOption: string, defaultEmailRecipientsFilter?: string | null) => {
    const tiers = useFilterableApi<Tier, 'tiers', 'name'>({path: '/tiers/', filterKey: 'name', responseKey: 'tiers'});
    const labels = useFilterableApi<Label, 'labels', 'name'>({path: '/labels/', filterKey: 'name', responseKey: 'labels'});
    const offers = useFilterableApi<Offer, 'offers', 'name'>({path: '/offers/', filterKey: 'name', responseKey: 'offers'});

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 Newsletters has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const Newsletters: React.FC<{ keywords: string[] }> = ({keywords}) => {
    const {updateRoute} = useRouting();
    const openNewsletterModal = () => {
        updateRoute('newsletters/new');
    };
Severity: Minor
Found in apps/admin-x-settings/src/components/settings/email/Newsletters.tsx - About 1 hr to fix

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 CustomIntegrationModalContent has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const CustomIntegrationModalContent: React.FC<{integration: Integration}> = ({integration}) => {
    const modal = useModal();
    const {updateRoute} = useRouting();

    const {mutateAsync: editIntegration} = useEditIntegration();

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 Toggle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const Toggle: React.FC<ToggleProps> = ({
    size,
    direction,
    label,
    labelStyle = 'value',
Severity: Minor
Found in apps/admin-x-design-system/src/global/form/Toggle.tsx - About 1 hr to fix

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 PageHeader has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const PageHeader: React.FC<PageHeaderProps> = ({
    left,
    center,
    right,
    sticky = true,
Severity: Minor
Found in apps/admin-x-design-system/src/global/layout/PageHeader.tsx - About 1 hr to fix

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 APReplyBox has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const APReplyBox: React.FC<APTextAreaProps> = ({
    title,
    value,
    rows = 1,
    maxLength,
Severity: Minor
Found in apps/admin-x-activitypub/src/components/global/APReplyBox.tsx - About 1 hr to fix

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 useHandleError has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

const useHandleError = () => {
    const {sentryDSN} = useFramework();

    /**
     * @param error Thrown error.
Severity: Minor
Found in apps/admin-x-framework/src/hooks/useHandleError.ts - About 1 hr to fix

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 _fetchEmailData has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async _fetchEmailData() {
        let {html, subject} = this;

        // Fetch newsletter
        if (!this.newsletter && this.args.data.newsletter) {
Severity: Minor
Found in ghost/admin/app/components/modals/email-preview.js - About 1 hr to fix

    Function setDate has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @action
        setDate(dateStr) {
            this.error = null;
    
            if (!dateStr.match(/^\d\d\d\d-\d\d-\d\d$/)) {
    Severity: Minor
    Found in ghost/admin/app/components/gh-date-picker.js - About 1 hr to fix

      Function constructor has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          constructor({
              Member,
              MemberNewsletter,
              MemberCancelEvent,
              MemberSubscribeEventModel,
      Severity: Minor
      Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 hr to fix

        Function getMRR has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            getMRR({interval, amount, status = null, canceled = false, discount = null}) {
                if (status === 'trialing') {
                    return 0;
                }
                if (status === 'incomplete') {
        Severity: Minor
        Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language