TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Offer has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

class Offer {
    events = [];
    get id() {
        return this.props.id.toHexString();
    }
Severity: Minor
Found in ghost/offers/lib/domain/models/Offer.js - About 2 hrs to fix

    Member has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    const Member = ghostBookshelf.Model.extend({
        tableName: 'members',
    
        defaults() {
            return {
    Severity: Minor
    Found in ghost/core/core/server/models/member.js - About 2 hrs to fix

      I18n has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class I18n {
          /**
           * @param {object} [options]
           * @param {string} options.basePath - the base path to the translations directory
           * @param {string} [options.locale] - a locale string
      Severity: Minor
      Found in ghost/core/core/frontend/services/theme-engine/i18n/I18n.js - About 2 hrs to fix

        Function edit has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async edit(settings, options, stripeConnectData) {
                let filteredSettings = settings.filter((setting) => {
                    // The `stripe_connect_integration_token` "setting" is only used to set the `stripe_connect_*` settings.
                    return ![
                        'stripe_connect_integration_token',
        Severity: Major
        Found in ghost/core/core/server/services/settings/SettingsBREADService.js - About 2 hrs to fix

          Function setupSiteApp has 70 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function setupSiteApp(routerConfig) {
              debug('Site setup start', routerConfig);
          
              const siteApp = express('site');
          
          
          Severity: Major
          Found in ghost/core/core/frontend/web/site.js - About 2 hrs to fix

            File authors.js has 283 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            const _ = require('lodash');
            const tpl = require('@tryghost/tpl');
            const errors = require('@tryghost/errors');
            const {sequence} = require('@tryghost/promise');
            
            
            Severity: Minor
            Found in ghost/core/core/server/models/relations/authors.js - About 2 hrs to fix

              File PopupModal.js has 283 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import React from 'react';
              import Frame from './Frame';
              import {hasMode} from '../utils/check-mode';
              import AppContext from '../AppContext';
              import {getFrameStyles} from './Frame.styles';
              Severity: Minor
              Found in apps/portal/src/components/PopupModal.js - About 2 hrs to fix

                File parse-member-event.js has 282 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import Helper from '@ember/component/helper';
                import moment from 'moment-timezone';
                import {getNonDecimal, getSymbol} from 'ghost-admin/utils/currency';
                import {ghPluralize} from 'ghost-admin/helpers/gh-pluralize';
                import {inject as service} from '@ember/service';
                Severity: Minor
                Found in ghost/admin/app/helpers/parse-member-event.js - About 2 hrs to fix

                  Function mockStats has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export default function mockStats(server) {
                      server.get('/stats/subscriptions/', function () {
                          return {
                              stats: [],
                              meta: {
                  Severity: Major
                  Found in ghost/admin/mirage/config/stats.js - About 2 hrs to fix

                    Function _getSubscriptionCheckoutData has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        async _getSubscriptionCheckoutData(body) {
                            const tierId = body.tierId;
                            const offerId = body.offerId;
                    
                            let cadence = body.cadence;
                    Severity: Major
                    Found in ghost/members-api/lib/controllers/RouterController.js - About 2 hrs to fix

                      Function replaceIdentifiers has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          replaceIdentifiers() {
                              const ownerUserId = _.find(this.requiredExistingData.users, (user) => {
                                  if (user.roles[0].name === 'Owner') {
                                      return true;
                                  }
                      Severity: Major
                      Found in ghost/core/core/server/data/importer/importers/data/PostsImporter.js - About 2 hrs to fix

                        Function up has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            async function up(knex) {
                                logging.info('Checking default_content_visibility for specific tiers');
                        
                                const settings = await knex('settings')
                                    .select()

                          Function each has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              _.each(columns, function each(columnKey) {
                                  let message = ''; // KEEP: Validator.js only validates strings.
                                  const strVal = _.toString(model.get(columnKey));
                          
                                  if (options.method !== 'insert' && !_.has(model.changed, columnKey)) {
                          Severity: Major
                          Found in ghost/core/core/server/data/schema/validator.js - About 2 hrs to fix

                            Function getImageDimensions has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            async function getImageDimensions(metaData) {
                                const MAX_SOCIAL_IMG_WIDTH = config.get('imageOptimization:internalImageSizes:social-image:width') || 1200;
                            
                                const fetch = {
                                    coverImage: imageSizeCache.getCachedImageSizeFromUrl(metaData.coverImage.url),
                            Severity: Major
                            Found in ghost/core/core/frontend/meta/image-dimensions.js - About 2 hrs to fix

                              Function add has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  async add(data, options) {
                                      if (!this.stripeService.configured && (data.comped || data.stripe_customer_id)) {
                                          const property = data.comped ? 'comped' : 'stripe_customer_id';
                                          throw new errors.ValidationError({
                                              message: tpl(messages.stripeNotConnected),
                              Severity: Minor
                              Found in ghost/members-api/lib/services/MemberBREADService.js - About 2 hrs 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 mediaValidation has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                              Open

                              const mediaValidation = function ({type}) {
                                  return function mediaUploadValidation(req, res, next) {
                                      const extensions = (config.get('uploads')[type] && config.get('uploads')[type].extensions) || [];
                                      const contentTypes = (config.get('uploads')[type] && config.get('uploads')[type].contentTypes) || [];
                              
                              
                              Severity: Minor
                              Found in ghost/core/core/server/web/api/middleware/upload.js - About 2 hrs 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 render has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  render() {
                                      const {page, pageQuery, site, customSiteUrl} = this.context;
                                      const products = getSiteProducts({site});
                                      const noOfProducts = products.length;
                              
                              
                              Severity: Minor
                              Found in apps/portal/src/components/PopupModal.js - About 2 hrs 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 getPageFromLinkPath has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  getPageFromLinkPath(path) {
                                      const customPricesSignupRegex = /^signup\/?(?:\/(\w+?))?\/?$/;
                                      const customMonthlyProductSignup = /^signup\/?(?:\/(\w+?))\/monthly\/?$/;
                                      const customYearlyProductSignup = /^signup\/?(?:\/(\w+?))\/yearly\/?$/;
                                      const customOfferRegex = /^offers\/(\w+?)\/?$/;
                              Severity: Minor
                              Found in apps/portal/src/App.js - About 2 hrs 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 20 (exceeds 5 allowed). Consider refactoring.
                              Open

                              export const getPortalPreviewUrl = ({settings, config, tiers, siteData, selectedTab} : portalPreviewUrlTypes): string | null => {
                                  if (!siteData?.url) {
                                      return null;
                                  }
                                  let portalTiers = tiers.filter((t) => {
                              Severity: Minor
                              Found in apps/admin-x-settings/src/utils/getPortalPreviewUrl.ts - About 2 hrs 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 ThemePreview has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                              Open

                              }> = ({
                                  selectedTheme,
                                  isInstalling,
                                  installedTheme,
                                  onBack,

                              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