TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function _validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    _validate() {
        let files = this.files;
        let validate = this.validate || this._defaultValidator.bind(this);
        let ok = [];
        let errors = [];
Severity: Minor
Found in ghost/admin/app/components/gh-uploader.js - About 25 mins 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 focusEditor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    @action
    focusEditor(event) {
        if (!this.skipFocusEditor && event.target.classList.contains('gh-koenig-editor-pane') && this.editorAPI) {
            let editorCanvas = this.editorAPI.editorInstance.getRootElement();
            let {bottom} = editorCanvas.getBoundingClientRect();
Severity: Minor
Found in ghost/admin/app/components/gh-koenig-editor-lexical.js - About 25 mins 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 passwordChange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    passwordChange(model) {
        let newPassword = model.newPassword;
        let ne2Password = model.ne2Password;

        // validation only marks the requested property as validated so we
Severity: Minor
Found in ghost/admin/app/validators/user.js - About 25 mins 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 drag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    @action
    drag(e) {
        e.preventDefault();

        let eventX, eventY;
Severity: Minor
Found in ghost/admin/app/modifiers/movable.js - About 25 mins 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 handleRouteWillChange has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    @action
    handleRouteWillChange({from, to}) {
        let normalizedToRoute = to && to.name.replace(/_loading$/, '');

        if (from && from.name === this.args.route && normalizedToRoute !== this.args.route) {
Severity: Minor
Found in ghost/admin/app/components/gh-link-to-custom-views-index.js - About 25 mins 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 setCollectionProperty has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    @action
    setCollectionProperty(property, newValue) {
        const {collection} = this.args;

        if (newValue) {
Severity: Minor
Found in ghost/admin/app/components/collections/collection-form.js - About 25 mins 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 versionMismatchHandler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const versionMismatchHandler = (APIVersionCompatibilityService) => {
    /**
     * @param {Object} err
     * @param {import('express').Request} req
     * @param {import('express').Response} res
Severity: Minor
Found in ghost/mw-api-version-mismatch/lib/mw-api-version-mismatch.js - About 25 mins 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 cancelSubscription has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async cancelSubscription(data, options) {
        const sharedOptions = {
            transacting: options ? options.transacting : null
        };
        if (!this._stripeAPIService.configured) {
Severity: Minor
Found in ghost/members-api/lib/repositories/MemberRepository.js - About 25 mins 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 populateMembersMonthlyPriceIdSettings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

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

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

    async notifyDonationReceived({donationPaymentEvent}) {
        const emailPromises = [];
        const users = await this.models.User.getEmailAlertUsers('donation');
        const formattedAmount = this.getFormattedAmount({currency: donationPaymentEvent.currency, amount: donationPaymentEvent.amount / 100});

Severity: Minor
Found in ghost/staff-service/lib/StaffServiceEmails.js - About 25 mins 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 prepareErrorCacheControl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.prepareErrorCacheControl = function prepareErrorCacheControl(cacheControlHeaderValue) {
    return function prepareErrorCacheControlInner(err, req, res, next) {
        let cacheControl = cacheControlHeaderValue;
        if (!cacheControlHeaderValue) {
            // never cache errors unless it's a 404
Severity: Minor
Found in ghost/mw-error-handler/lib/mw-error-handler.js - About 25 mins 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 all has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    all(apiConfig, frame) {
        debug('serialize all');

        if (frame.options.include) {
            frame.options.withRelated = utils.options.trimAndLowerCase(frame.options.include);
Severity: Minor
Found in ghost/api-framework/lib/serializers/input/all.js - About 25 mins 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 output has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.output = (response = {}, apiConfig, apiSerializers, frame) => {
    debug('output');

    const tasks = [];

Severity: Minor
Found in ghost/api-framework/lib/serializers/handle.js - About 25 mins 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 notifyMilestoneReceived has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async notifyMilestoneReceived({milestone}) {
        if (!milestone?.emailSentAt || milestone?.meta?.reason) {
            // Do not send an email when no email was set to be sent or a reason
            // not to send provided
            return;
Severity: Minor
Found in ghost/staff-service/lib/StaffServiceEmails.js - About 25 mins 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 _resolveContextSource has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    _resolveContextSource(context) {
        let source;

        if (context.import || context.importer) {
            source = 'import';
Severity: Minor
Found in ghost/members-api/lib/repositories/MemberRepository.js - About 25 mins 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 _handleMemberCreatedEvent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async _handleMemberCreatedEvent(event) {
        const source = event.data?.source;
        let sourceThreshold;

        if (source === 'api') {
Severity: Minor
Found in ghost/verification-trigger/lib/VerificationTrigger.js - About 25 mins 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 fetchSubscriptionOffers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async fetchSubscriptionOffers(subscriptions) {
        const fetchedOffers = new Map();
        const subscriptionOffers = new Map();

        try {
Severity: Minor
Found in ghost/members-api/lib/services/MemberBREADService.js - About 25 mins 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 getPriceForTierCadence has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async getPriceForTierCadence(tier, cadence) {
        const product = await this.getProductForTier(tier);
        const currency = tier.currency.toLowerCase();
        const amount = tier.getPrice(cadence);
        const rows = await this.StripePriceModel.where({
Severity: Minor
Found in ghost/payments/lib/PaymentsService.js - About 25 mins 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 revertPortalPlansSetting has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    async revertPortalPlansSetting(options) {
        if (!options) {
            return this.models.Product.transaction((transacting) => {
                return this.revertPortalPlansSetting({transacting});
            });
Severity: Minor
Found in ghost/stripe/lib/StripeMigrations.js - About 25 mins 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