TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function ThemeToolbar has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

const ThemeToolbar: React.FC<ThemeToolbarProps> = ({
    currentTab,
    setCurrentTab,
    themes
}) => {
Severity: Minor
Found in apps/admin-x-settings/src/components/settings/site/ThemeModal.tsx - About 5 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 generate has 139 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    generate() {
        this.count += 1;

        const member = this.model;
        const customer = this.membersStripeCustomers.get(this.model.id);

    Function DetailPage has 139 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const DetailPage: React.FC = () => {
        const {updateRoute} = useRouting();
    
        return (
            <Page
    Severity: Major
    Found in apps/admin-x-demo/src/DetailPage.tsx - About 5 hrs to fix

      File commands.js has 397 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      const _ = require('lodash');
      const logging = require('@tryghost/logging');
      const errors = require('@tryghost/errors');
      const tpl = require('@tryghost/tpl');
      const db = require('../db');
      Severity: Minor
      Found in ghost/core/core/server/data/schema/commands.js - About 5 hrs to fix

        File member.js has 396 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        const ghostBookshelf = require('./base');
        const crypto = require('crypto');
        const _ = require('lodash');
        const config = require('../../shared/config');
        
        
        Severity: Minor
        Found in ghost/core/core/server/models/member.js - About 5 hrs to fix

          Function fetchQueryStrData has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
          Open

              fetchQueryStrData(qs = '') {
                  const qsParams = new URLSearchParams(qs);
                  const data = {
                      site: {
                          plans: {}
          Severity: Minor
          Found in apps/portal/src/App.js - About 5 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 GlobalSettings has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
          Open

          const GlobalSettings: React.FC<{ values: GlobalSettingValues, updateSetting: (key: string, value: SettingValue) => void }> = ({values,updateSetting}) => {
              const {mutateAsync: uploadImage} = useUploadImage();
              const {settings} = useGlobalData();
              const [unsplashEnabled] = getSettingValues<boolean>(settings, ['unsplash']);
              const [showUnsplash, setShowUnsplash] = useState<boolean>(false);

          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

          File Modal.tsx has 391 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import {useModal} from '@ebay/nice-modal-react';
          import clsx from 'clsx';
          import React, {useEffect, useState} from 'react';
          import useGlobalDirtyState from '../../hooks/useGlobalDirtyState';
          import {confirmIfDirty} from '../../utils/modals';
          Severity: Minor
          Found in apps/admin-x-design-system/src/global/modal/Modal.tsx - About 5 hrs to fix

            File spam-prevention.js has 387 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 5 hrs to fix

              Function create has 130 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async create(data, options = {}) {
                      if (!this._stripeAPIService.configured && (data.stripe_prices || data.monthly_price || data.yearly_price)) {
                          throw new UpdateCollisionError({
                              message: 'The requested functionality requires Stripe to be configured. See https://ghost.org/integrations/stripe/',
                              code: 'STRIPE_NOT_CONFIGURED'
              Severity: Major
              Found in ghost/members-api/lib/repositories/ProductRepository.js - About 5 hrs to fix

                Function ghost_head has 129 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 5 hrs to fix

                  Function draw has 128 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  Chart.elements.Rectangle.prototype.draw = function () {
                      var ctx = this._chart.ctx;
                      var vm = this._view;
                      var left, right, top, bottom, borderSkipped, radius;
                  
                  
                  Severity: Major
                  Found in ghost/admin/app/components/dashboard/charts/paid-mix.js - About 5 hrs to fix

                    Function chartOptions has 128 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        get chartOptions() {
                            const that = this;
                            let activeDays = this.dashboardStats.chartDays;
                            let barColor = this.feature.nightShift ? 'rgba(200, 204, 217, 0.25)' : 'rgba(200, 204, 217, 0.65)';
                    
                    
                    Severity: Major
                    Found in ghost/admin/app/components/dashboard/charts/anchor-attribution.js - About 5 hrs to fix

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

                      module.exports = function (Bookshelf) {
                          const insertAction = (data, options) => {
                              // CASE: model does not support action for target event
                              if (!data) {
                                  return;
                      Severity: Major
                      Found in ghost/core/core/server/models/base/plugins/actions.js - About 5 hrs to fix

                        Function updateMockedData has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                        Open

                            updateMockedData({days}) {
                                const generateDays = days;
                                const startDate = new Date();
                                startDate.setDate(startDate.getDate() - generateDays + 1);
                        
                        
                        Severity: Minor
                        Found in ghost/admin/app/services/dashboard-mocks.js - About 5 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 a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                        Open

                            permissible: async function permissible(userModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
                                const self = this;
                                const userModel = userModelOrId;
                                let origArgs;
                        
                        
                        Severity: Minor
                        Found in ghost/core/core/server/models/user.js - About 5 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 getTitle has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                        Open

                        function getTitle(data, root, options = {}) {
                            const context = root ? root.context : null;
                            const siteTitle = settingsCache.get('title') || '';
                            const pagination = root ? root.pagination : null;
                        
                        
                        Severity: Minor
                        Found in ghost/core/core/frontend/meta/title.js - About 5 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 Modal has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                        Open

                        const Modal: React.FC<ModalProps> = ({
                            size = 'md',
                            align = 'center',
                            width,
                            height,
                        Severity: Minor
                        Found in apps/admin-x-design-system/src/global/modal/Modal.tsx - About 5 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

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

                        module.exports = class StripeAPI {
                            /**
                             * StripeAPI
                             */
                            constructor(deps) {
                        Severity: Minor
                        Found in ghost/stripe/lib/StripeAPI.js - About 5 hrs to fix

                          Function create has 123 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              async create(data, options) {
                                  if (!options) {
                                      options = {};
                                  }
                          
                          
                          Severity: Major
                          Found in ghost/members-api/lib/repositories/MemberRepository.js - About 4 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language