TryGhost/Ghost

View on GitHub

Showing 1,756 of 3,886 total issues

Function ViewContainer has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

const ViewContainer: React.FC<ViewContainerProps> = ({
    type,
    title,
    firstOnPage = true,
    headerContent,
Severity: Minor
Found in apps/admin-x-design-system/src/global/layout/ViewContainer.tsx - About 4 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 ghost_head has 109 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = async function ghost_head(options) { // eslint-disable-line camelcase
    debug('begin');

    // if server error page do nothing
    if (options.data.root.statusCode >= 500) {
Severity: Major
Found in ghost/core/core/frontend/helpers/ghost_head.js - About 4 hrs to fix

    File settings.js has 348 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const _ = require('lodash');
    const uuid = require('uuid');
    const crypto = require('crypto');
    const keypair = require('keypair');
    const ObjectID = require('bson-objectid').default;
    Severity: Minor
    Found in ghost/core/core/server/models/settings.js - About 4 hrs to fix

      File TierDetailModal.tsx has 348 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import NiceModal, {useModal} from '@ebay/nice-modal-react';
      import React, {useEffect, useRef} from 'react';
      import TierDetailPreview from './TierDetailPreview';
      import useFeatureFlag from '../../../../hooks/useFeatureFlag';
      import useSettingGroup from '../../../../hooks/useSettingGroup';

        exports has 34 functions (exceeds 20 allowed). Consider refactoring.
        Open

        module.exports = {
            get all() {
                return require('./all');
            },
        
        

          Function setComplimentarySubscription has 108 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              async setComplimentarySubscription(data, options = {}) {
                  if (!options.transacting) {
                      return this._Member.transaction((transacting) => {
                          return this.setComplimentarySubscription(data, {
                              ...options,
          Severity: Major
          Found in ghost/members-api/lib/repositories/MemberRepository.js - About 4 hrs to fix

            File validate.js has 345 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            const _ = require('lodash');
            const tpl = require('@tryghost/tpl');
            const errors = require('@tryghost/errors');
            const _private = {};
            let RESOURCE_CONFIG;
            Severity: Minor
            Found in ghost/core/core/server/services/route-settings/validate.js - About 4 hrs to fix

              Function http has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
              Open

              const http = (apiImpl) => {
                  /**
                   * @param {import('express').Request} req - Express request object.
                   * @param {import('express').Response} res - Express response object.
                   * @param {import('express').NextFunction} next - Express next function.
              Severity: Minor
              Found in ghost/api-framework/lib/http.js - About 4 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 permissible has 105 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  permissible: async function permissible(userModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
                      const self = this;
                      const userModel = userModelOrId;
                      let origArgs;
              
              
              Severity: Major
              Found in ghost/core/core/server/models/user.js - About 4 hrs to fix

                Function ZapierModal has 103 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const ZapierModal = NiceModal.create(() => {
                    const modal = NiceModal.useModal();
                    const {updateRoute} = useRouting();
                    const {zapierTemplates} = useSettingsApp();
                    const {data: {integrations} = {integrations: []}} = useBrowseIntegrations();

                  Function AnnouncementBarModal has 103 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const AnnouncementBarModal: React.FC = () => {
                      const {siteData} = useGlobalData();
                      const {localSettings, updateSetting, handleSave, okProps} = useSettingGroup({savingDelay: 500});
                      const [announcementContent] = getSettingValues<string>(localSettings, ['announcement_content']);
                      const [accentColor] = getSettingValues<string>(localSettings, ['accent_color']);

                    File post.js has 338 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import Ember from 'ember';
                    import Model, {attr, belongsTo, hasMany} from '@ember-data/model';
                    import ValidationEngine from 'ghost-admin/mixins/validation-engine';
                    import boundOneWay from 'ghost-admin/utils/bound-one-way';
                    import moment from 'moment-timezone';
                    Severity: Minor
                    Found in ghost/admin/app/models/post.js - About 4 hrs to fix

                      File data-attributes.js has 337 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      /* eslint-disable no-console */
                      import {getCheckoutSessionDataFromPlanAttribute, getUrlHistory} from './utils/helpers';
                      import {HumanReadableError} from './utils/errors';
                      
                      export function formSubmitHandler({event, form, errorEl, siteUrl, submitHandler}) {
                      Severity: Minor
                      Found in apps/portal/src/data-attributes.js - About 4 hrs to fix

                        Function PreviewModalContent has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const PreviewModalContent: React.FC<PreviewModalProps> = ({
                            testId,
                            title,
                            titleHeadingLevel = 4,
                            size = 'full',
                        Severity: Minor
                        Found in apps/admin-x-design-system/src/global/modal/PreviewModal.tsx - About 4 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 chartOptions has 102 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            get chartOptions() {
                                const barColor = this.feature.nightShift ? 'rgba(200, 204, 217, 0.25)' : 'rgba(200, 204, 217, 0.65)';
                        
                                return {
                                    responsive: true,
                        Severity: Major
                        Found in ghost/admin/app/components/dashboard/charts/paid-breakdown.js - About 4 hrs to fix

                          Function init has 102 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              init() {
                                  if (this.service) {
                                      return;
                                  }
                          
                          
                          Severity: Major
                          Found in ghost/core/core/server/services/email-service/EmailServiceWrapper.js - About 4 hrs to fix

                            File members-api.js has 336 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            const {Router} = require('express');
                            const body = require('body-parser');
                            const MagicLink = require('@tryghost/magic-link');
                            const errors = require('@tryghost/errors');
                            const logging = require('@tryghost/logging');
                            Severity: Minor
                            Found in ghost/members-api/lib/members-api.js - About 4 hrs to fix

                              File spam-prevention.js has 333 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              const moment = require('moment');
                              const extend = require('lodash/extend');
                              const pick = require('lodash/pick');
                              const errors = require('@tryghost/errors');
                              const config = require('../../../../../shared/config');
                              Severity: Minor
                              Found in ghost/core/core/server/web/shared/middleware/api/spam-prevention.js - About 4 hrs to fix

                                File dashboard-mocks.js has 332 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                import Service from '@ember/service';
                                import {tracked} from '@glimmer/tracking';
                                
                                /**
                                 * @typedef {import('./dashboard-stats').MemberCountStat} MemberCountStat
                                Severity: Minor
                                Found in ghost/admin/app/services/dashboard-mocks.js - About 4 hrs to fix

                                  Function exports has 99 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  module.exports = function (Bookshelf) {
                                      Bookshelf.Model = Bookshelf.Model.extend({
                                          // Ghost option handling - get permitted attributes from server/data/schema.js, where the DB schema is defined
                                          permittedAttributes: function permittedAttributes() {
                                              return _.keys(schema.tables[this.tableName])
                                  Severity: Major
                                  Found in ghost/core/core/server/models/base/plugins/sanitize.js - About 3 hrs to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language