TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function processPayload has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async processPayload(payload: Payload) {
        if (this.labs.isSet(MailEventService.LABS_KEY) === false) {
            throw new errors.NotFoundError();
        }

Severity: Minor
Found in ghost/mail-events/src/MailEventService.ts - About 1 hr to fix

    Function onSave has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            onSave: async () => {
                const {trial_days: trialDays, currency, ...rest} = formState;
                const values: Partial<Tier> = rest;
    
                values.benefits = values.benefits?.filter(benefit => benefit);

      Function PopupBox has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const PopupBox: React.FC<Props> = () => {
          const {popup} = useAppContext();
      
          // To make sure we can properly animate a popup that goes away, we keep a state of the last visible popup
          // This way, when the popup context is set to null, we still can show the popup while we transition it away
      Severity: Minor
      Found in apps/comments-ui/src/components/PopupBox.tsx - About 1 hr to fix

        Function generate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            generate() {
                // We need to add all properties here already otherwise CSV imports won't know all the columns
                let attribution = {
                    attribution_id: null,
                    attribution_type: null,

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

        function getAction(ev) {
            let resourceType = ev.resource_type;
        
            if (resourceType === 'api_key') {
                resourceType = 'API key';
        Severity: Minor
        Found in ghost/admin/app/helpers/parse-history-event.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 finalise has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            async finalise() {
                const stripeProducts = await this.transaction.select('id', 'product_id', 'stripe_product_id').from('stripe_products');
                const stripePrices = await this.transaction.select('id', 'stripe_product_id', 'interval').from('stripe_prices');
        
                const products = await this.transaction.select('id').from('products');
        Severity: Minor
        Found in ghost/data-generator/lib/importers/ProductsImporter.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 getSentryConfig has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        export function getSentryConfig(dsn, environment, appVersion, transport) {
            const extraIntegrations = [];
        
            const config = {
                dsn,
        Severity: Minor
        Found in ghost/admin/app/utils/sentry.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 generate has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            generate() {
                let timestamp = this.events.pop();
                if (!timestamp) {
                    return;
                }
        Severity: Minor
        Found in ghost/data-generator/lib/importers/EmailRecipientsImporter.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 visibilitySegment has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            visibilitySegment: computed('visibility', 'isPublic', 'tiers', function () {
                if (this.isPublic) {
                    return this.settings.defaultContentVisibility === 'paid' ? 'status:-free' : 'status:free,status:-free';
                } else {
                    if (this.visibility === 'members') {
        Severity: Minor
        Found in ghost/admin/app/models/post.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 handleNotification has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            handleNotification(message, delayed = false) {
                const wordRegex = /[a-z]+/igm;
                const wordMatches = (message.message.string || message.message).matchAll(wordRegex);
        
                for (const wordMatch of wordMatches) {
        Severity: Minor
        Found in ghost/admin/app/services/notifications.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 getPortalPreviewUrl has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            getPortalPreviewUrl(overrides) {
                let {
                    disableBackground = false,
                    page = 'signup',
                    button = this.settings.portalButton,
        Severity: Minor
        Found in ghost/admin/app/services/members-utils.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 loadState has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            loadState() {
                try {
                    const savedState = localStorage.getItem('dashboard5-prototype-state');
                    if (savedState) {
                        const parsed = JSON.parse(savedState);
        Severity: Minor
        Found in ghost/admin/app/components/dashboard/prototype/control-panel.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 populateStripePricesFromStripePlansSetting has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            async populateStripePricesFromStripePlansSetting(options) {
                if (!options) {
                    return this.models.Product.transaction((transacting) => {
                        return this.populateStripePricesFromStripePlansSetting({transacting});
                    });
        Severity: Minor
        Found in ghost/stripe/lib/StripeMigrations.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 unparse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        const unparse = (rows, columns = DEFAULT_COLUMNS.slice()) => {
            columns = columns.map((column) => {
                if (column === 'subscribed') {
                    return 'subscribed_to_emails';
                }
        Severity: Minor
        Found in ghost/members-csv/lib/unparse.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 get has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            async get(data, options = {}) {
                if (!options.transacting) {
                    return this._Product.transaction((transacting) => {
                        return this.get(data, {
                            ...options,
        Severity: Minor
        Found in ghost/members-api/lib/repositories/ProductRepository.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 getPaymentLink has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            async getPaymentLink({tier, cadence, offer, member, metadata, successUrl, cancelUrl, email}) {
                let coupon = null;
                let trialDays = null;
                if (offer) {
                    if (!tier.id.equals(offer.tier.id)) {
        Severity: Minor
        Found in ghost/payments/lib/PaymentsService.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 handleEvent has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            async handleEvent(type, event) {
                if (type === MilestoneCreatedEvent && event.data.milestone) {
                    await this.emails.notifyMilestoneReceived(event.data);
                }
        
        
        Severity: Minor
        Found in ghost/staff-service/lib/StaffService.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 _createSubscriptionCheckoutSession has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            async _createSubscriptionCheckoutSession(options) {
                if (options.offer) {
                    // Attach offer information to stripe metadata for free trial offers
                    // free trial offers don't have associated stripe coupons
                    options.metadata.offer = options.offer.id;
        Severity: Minor
        Found in ghost/members-api/lib/controllers/RouterController.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 edit has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            async edit(data, options) {
                delete data.last_seen_at;
        
                let model;
        
        
        Severity: Minor
        Found in ghost/members-api/lib/services/MemberBREADService.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 extraFilters has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            extraFilters: function extraFilters(options) {
                if (!options.status) {
                    return null;
                }
        
        
        Severity: Minor
        Found in ghost/core/core/server/models/post.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

        Severity
        Category
        Status
        Source
        Language