TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function import has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    async import() {
        let offset = 0;
        let limit = 5000;
        this.products = await this.transaction.select('id', 'name').from('products').whereNot('type', 'free');
        this.stripeProducts = await this.transaction.select('id', 'product_id', 'stripe_product_id').from('stripe_products');

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

    addToUrl(url, useNewsletter) {
        // Create a deep copy
        url = new URL(url);

        if (!this.isEnabled) {
Severity: Minor
Found in ghost/member-attribution/lib/OutboundLinkTagger.js - About 55 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 humanizeRecipientFilter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export default helper(function humanizeRecipientFilter([filter = '']/*, hash*/) {
    const parts = filter.split(',');

    if (parts.includes('status:free') && parts.includes('status:-free')) {
        return 'All subscribers';
Severity: Minor
Found in ghost/admin/app/helpers/humanize-recipient-filter.js - About 55 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 saveTask has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    saveTask: task(function* () {
        let label = this.model && this.model.label;
        let availableLabels = (this.model && this.model.labels) || [];
        if (!label) {
            return false;
Severity: Minor
Found in ghost/admin/app/components/modal-members-label-form.js - About 55 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 _handleSubscriptionUpdate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    _handleSubscriptionUpdate(data) {
        this.billing.subscription = data.subscription;
        this.billing.checkoutRoute = data?.checkoutRoute ?? '/plans';

        if (data.subscription.status === 'active' && this.config.hostSettings?.forceUpgrade) {
Severity: Minor
Found in ghost/admin/app/components/gh-billing-iframe.js - About 55 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 getPosts has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export function getPosts({posts}, {queryParams}) {
    let {filter, page, limit} = queryParams;

    page = +page || 1;
    limit = +limit || 15;
Severity: Minor
Found in ghost/admin/mirage/config/posts.js - About 55 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 paginateModelCollection has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export function paginateModelCollection(modelName, collection, page, limit) {
    let pages, next, prev, models;

    if (limit === 'all') {
        pages = 1;
Severity: Minor
Found in ghost/admin/mirage/utils.js - About 55 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 onDateKeydown has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    @action
    onDateKeydown(datepicker, event) {
        if (event.key === 'Escape') {
            this._resetScratchDate();
        }
Severity: Minor
Found in ghost/admin/app/components/gh-date-time-picker.js - About 55 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 closeWhenEmpty has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    @action
    closeWhenEmpty() {
        if (document.activeElement === this.inputElem) {
            if (this.args.extra?.closeWhenEmpty) {
                if (this.args.select.results.length > 0) {
Severity: Minor
Found in ghost/admin/app/components/gh-input-with-select/trigger.js - About 55 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 handleIframeMessage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    @action
    async handleIframeMessage(event) {
        if (this.isDestroyed || this.isDestroying) {
            return;
        }
Severity: Minor
Found in ghost/admin/app/components/gh-migrate-iframe.js - About 55 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 onKeyDown has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    @action
    onKeyDown(event) {
        if (event.key === 'Control') {
            this.ctrlPressed = true;
        }
Severity: Minor
Found in ghost/admin/app/components/multi-list/list.js - About 55 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 passwordValidation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    passwordValidation(model, password, errorTarget) {
        let blogUrl = model.config?.blogUrl || window.location.host;
        let blogTitle = model.blogTitle || model.config?.blogTitle;
        let blogUrlWithSlash;

Severity: Minor
Found in ghost/admin/app/validators/mixins/password.js - About 55 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 validityDetails has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export function validityDetails(data, separatorNeeded = false) {
    const separator = separatorNeeded ? ' – ' : '';
    const space = data.validUntil ? ' ' : '';

    if (data.isComplimentary) {
Severity: Minor
Found in ghost/admin/app/utils/subscription-data.js - About 55 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 _uploadError has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    _uploadError(error) {
        let message;
        let header = 'Import error';

        if (isVersionMismatchError(error)) {
Severity: Minor
Found in ghost/admin/app/components/modal-import-members.js - About 55 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 handleSubscriptionEvent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    async handleSubscriptionEvent(subscription) {
        const subscriptionPriceData = _.get(subscription, 'items.data');
        if (!subscriptionPriceData || subscriptionPriceData.length !== 1) {
            throw new errors.BadRequestError({
                message: 'Subscription should have exactly 1 price item'
Severity: Minor
Found in ghost/stripe/lib/services/webhook/SubscriptionEventService.js - About 55 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 input has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.input = (apiConfig, apiValidators, frame) => {
    debug('input begin');

    const tasks = [];
    const sharedValidators = require('./input');
Severity: Minor
Found in ghost/api-framework/lib/validators/handle.js - About 55 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 input has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.input = (apiConfig, apiSerializers, frame) => {
    debug('input');

    const tasks = [];
    const sharedSerializers = require('./input');
Severity: Minor
Found in ghost/api-framework/lib/serializers/handle.js - About 55 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 updateCheckRequest has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    async updateCheckRequest() {
        const reqData = await this.updateCheckData();

        let reqObj = {
            timeout: {
Severity: Minor
Found in ghost/update-check-service/lib/UpdateCheckService.js - About 55 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 add has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    add(apiConfig, frame) {
        debug('validate add');

        // NOTE: this block should be removed completely once JSON Schema validations
        //       are introduced for all of the endpoints
Severity: Minor
Found in ghost/api-framework/lib/validators/input/all.js - About 55 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 resourceNotFound has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

module.exports.resourceNotFound = function resourceNotFound(req, res, next) {
    if (req?.headers?.['accept-version'] && res.locals?.safeVersion) {
        // Protect against invalid `Accept-Version` headers
        const acceptVersionSemver = semver.coerce(req.headers['accept-version']);
        if (!acceptVersionSemver) {
Severity: Minor
Found in ghost/mw-error-handler/lib/mw-error-handler.js - About 55 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