TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function compute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    compute([senderEmail]) {
        const defaultEmail = this.settings.defaultEmailAddress;

        if (isManagedEmail(this.config) && !hasSendingDomain(this.config)) {
            // Not changeable: sender_email is ignored
Severity: Minor
Found in ghost/admin/app/helpers/sender-email-address.js - About 45 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 willTransition has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    @action
    willTransition(transition) {
        let isBillingTransition = false;

        if (transition) {
Severity: Minor
Found in ghost/admin/app/routes/pro.js - About 45 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 getStatsParams has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function getStatsParams(config, props, additionalParams = {}) {
    const {chartRange, audience, device, browser, location, source, pathname} = props;
    const {startDate, endDate} = getDateRange(chartRange);

    const params = {
Severity: Minor
Found in ghost/admin/app/utils/stats.js - About 45 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 feature has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function feature(name, options = {}) {
    let {user, onChange} = options;
    let watchedProps = user ? [`accessibility.${name}`] : [`config.${name}`, `labs.${name}`];

    return computed.apply(Ember, watchedProps.concat({
Severity: Minor
Found in ghost/admin/app/services/feature.js - About 45 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 swapIframes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    swapIframes(renderedIframe) {
        if (this.isDestroyed || this.isDestroying) {
            return;
        }

Severity: Minor
Found in ghost/admin/app/components/gh-html-iframe.js - About 45 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 setDate has a Cognitive Complexity of 8 (exceeds 5 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 45 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 chartOptions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    get chartOptions() {
        let chartTitle = 'Free signups';
        if (this.args.sortColumn === 'signups') {
            chartTitle = 'Free signups';
        } else {

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

    registerHelpers(handlebars, labs) {
        handlebars.registerHelper('if', function (conditional, options) {
            if (conditional) {
                return options.fn(this);
            } else {
Severity: Minor
Found in ghost/email-service/lib/helpers/register-helpers.js - About 45 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 updateCheckData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    async updateCheckData() {
        let data = {};
        let mailConfig = this.config.mail;

        data.ghost_version = this.config.ghostVersion;
Severity: Minor
Found in ghost/update-check-service/lib/UpdateCheckService.js - About 45 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

Avoid deeply nested control flow statements.
Open

                        if (this.isActiveSubscriptionStatus(subscriptionModel.get('status')) && subscriptionModel.id !== model.id) {
                            try {
                                const subscriptionProduct = await this._productRepository.get({stripe_price_id: subscriptionModel.get('stripe_price_id')}, options);
                                if (subscriptionProduct && previousProduct && subscriptionProduct.id === previousProduct.id) {
                                    activeSubscriptionForPreviousProduct = true;
Severity: Major
Found in ghost/members-api/lib/repositories/MemberRepository.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if (dontAllowToRemoveProductsIds.includes(deleteId)) {
                                throw new errors.BadRequestError({message: tpl(messages.deleteProductWithActiveSubscription)});
                            }
    Severity: Major
    Found in ghost/members-api/lib/repositories/MemberRepository.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if (!stripePrice) {
                              await this._StripePrice.add({
                                  stripe_price_id: existingPrice.stripe_price_id,
                                  stripe_product_id: stripeProduct.get('stripe_product_id'),
                                  active: existingPrice.active,
      Severity: Major
      Found in ghost/members-api/lib/repositories/ProductRepository.js - About 45 mins to fix

        Function exchangeTokenForSession has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            async exchangeTokenForSession(req, res) {
                if (!req.url) {
                    return Promise.reject(new BadRequestError({
                        message: 'Expected token param containing JWT'
                    }));
        Severity: Minor
        Found in ghost/members-ssr/lib/members-ssr.js - About 45 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

        Avoid deeply nested control flow statements.
        Open

                            if (!stripeProduct) {
                                stripeProduct = await this._StripeProduct.add({
                                    product_id: product.id,
                                    stripe_product_id: existingProductId
                                }, options);
        Severity: Major
        Found in ghost/members-api/lib/repositories/ProductRepository.js - About 45 mins to fix

          Function _pingUrl has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          SchedulingDefault.prototype._pingUrl = function (object) {
              const {url, time} = object;
          
              debug('Ping url', url, moment().format('YYYY-MM-DD HH:mm:ss'), moment(time).format('YYYY-MM-DD HH:mm:ss'));
          
          
          Severity: Minor
          Found in ghost/core/core/server/adapters/scheduling/scheduling-default.js - About 45 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 getSubscriptionEvents has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              async getSubscriptionEvents(options = {}, filter) {
                  options = {
                      ...options,
                      withRelated: [
                          'member',
          Severity: Minor
          Found in ghost/members-api/lib/repositories/EventRepository.js - About 45 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 getEventTimeline has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              async getEventTimeline(options = {}) {
                  if (!options.limit) {
                      options.limit = 10;
                  }
          
          
          Severity: Minor
          Found in ghost/members-api/lib/repositories/EventRepository.js - About 45 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 getHistory has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              async getHistory() {
                  // Fetch current total amounts and start counting from there
                  const totals = await this.getCurrentMrr();
          
                  const rows = await this.fetchAllDeltas();
          Severity: Minor
          Found in ghost/stats-service/lib/MrrStatsService.js - About 45 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 formatOnWrite has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              formatOnWrite(attrs) {
                  // Ensure all URLs are stored as transform-ready with __GHOST_URL__ representing config.url
                  const urlTransformMap = {
                      mobiledoc: {
                          method: 'mobiledocToTransformReady',
          Severity: Minor
          Found in ghost/core/core/server/models/post.js - About 45 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 format has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              format() {
                  const attrs = ghostBookshelf.Model.prototype.format.apply(this, arguments);
                  const settingType = attrs.type;
          
                  if (settingType === 'boolean') {
          Severity: Minor
          Found in ghost/core/core/server/models/custom-theme-setting.js - About 45 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