TryGhost/Ghost

View on GitHub

Showing 1,734 of 3,834 total issues

Function extendModel has 272 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports.extendModel = function extendModel(Post, Posts, ghostBookshelf) {
    const proto = Post.prototype;

    const Model = Post.extend({
        _handleOptions: function _handleOptions(fnName) {
Severity: Major
Found in ghost/core/core/server/models/relations/authors.js - About 1 day to fix

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

    import Frame from './Frame';
    import AppContext from '../AppContext';
    import {ReactComponent as SearchIcon} from '../icons/search.svg';
    import {ReactComponent as ClearIcon} from '../icons/clear.svg';
    import {ReactComponent as CircleAnimated} from '../icons/circle-anim.svg';
    Severity: Major
    Found in apps/sodo-search/src/components/PopupModal.js - About 1 day to fix

      Function update has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
      Open

          async update(data, options) {
              const sharedOptions = {
                  transacting: options.transacting
              };
      
      
      Severity: Minor
      Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 day 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 extendModel has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports.extendModel = function extendModel(Post, Posts, ghostBookshelf) {
          const proto = Post.prototype;
      
          const Model = Post.extend({
              _handleOptions: function _handleOptions(fnName) {
      Severity: Minor
      Found in ghost/core/core/server/models/relations/authors.js - About 1 day 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 update has 259 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async update(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 1 day to fix

        File AddOfferModal.tsx has 597 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import PortalFrame from '../../membership/portal/PortalFrame';
        import {Button} from '@tryghost/admin-x-design-system';
        import {ErrorMessages, useForm} from '@tryghost/admin-x-framework/hooks';
        import {Form, Icon, PreviewModalContent, Select, SelectOption, TextArea, TextField, showToast} from '@tryghost/admin-x-design-system';
        import {getHomepageUrl} from '@tryghost/admin-x-framework/api/site';

          Function updateMockedData has 258 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              updateMockedData({days}) {
                  const generateDays = days;
                  const startDate = new Date();
                  startDate.setDate(startDate.getDate() - generateDays + 1);
          
          
          Severity: Major
          Found in ghost/admin/app/services/dashboard-mocks.js - About 1 day to fix

            File OfferPage.js has 595 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import React from 'react';
            import ActionButton from '../common/ActionButton';
            import AppContext from '../../AppContext';
            import {ReactComponent as CheckmarkIcon} from '../../images/icons/checkmark.svg';
            import CloseButton from '../common/CloseButton';
            Severity: Major
            Found in apps/portal/src/components/pages/OfferPage.js - About 1 day to fix

              Function update has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
              Open

                  async update(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: Minor
              Found in ghost/members-api/lib/repositories/ProductRepository.js - About 1 day 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 UserDetailModalContent has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
              Open

              const UserDetailModalContent: React.FC<{user: User}> = ({user}) => {
                  const {updateRoute} = useRouting();
                  const {ownerUser} = useStaffUsers();
                  const {currentUser} = useGlobalData();
                  const handleError = useHandleError();

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

              const TierDetailModalContent: React.FC<{tier?: Tier}> = ({tier}) => {
                  const isFreeTier = tier?.type === 'free';
              
                  const modal = useModal();
                  const {updateRoute} = useRouting();

              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 apiRoutes has 246 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = function apiRoutes() {
                  const router = express.Router('admin api');
              
                  // alias delete with del
                  router.del = router.delete;
              Severity: Major
              Found in ghost/core/core/server/web/api/endpoints/admin/routes.js - About 1 day to fix

                File NewsletterDetailModal.tsx has 562 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import NewsletterPreview from './NewsletterPreview';
                import NiceModal from '@ebay/nice-modal-react';
                import React, {useCallback, useEffect, useMemo, useState} from 'react';
                import useFeatureFlag from '../../../../hooks/useFeatureFlag';
                import useSettingGroup from '../../../../hooks/useSettingGroup';

                  Function ListPage has 230 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const ListPage = () => {
                      const {updateRoute} = useRouting();
                      const [view, setView] = useState<string>('list');
                  
                      const dummyActions = [
                  Severity: Major
                  Found in apps/admin-x-demo/src/ListPage.tsx - About 1 day to fix

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

                    module.exports = {
                        get authentication() {
                            return apiFramework.pipeline(require('./authentication'), localUtils);
                        },
                    
                    
                    Severity: Major
                    Found in ghost/core/core/server/api/endpoints/index.js - About 1 day to fix

                      Function checkoutSessionEvent has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
                      Open

                          async checkoutSessionEvent(session) {
                              if (session.mode === 'setup') {
                                  const setupIntent = await this.api.getSetupIntent(session.setup_intent);
                                  const member = await this.deps.memberRepository.get({
                                      customer_id: setupIntent.metadata.customer_id
                      Severity: Minor
                      Found in ghost/stripe/lib/WebhookController.js - About 1 day 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 setupGhostApi has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) {
                          const apiPath = 'members/api';
                      
                          function endpointFor({type, resource}) {
                              if (type === 'members') {
                      Severity: Minor
                      Found in apps/portal/src/utils/api.js - About 1 day 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 Button has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const Button: React.FC<ButtonProps> = ({
                          testId,
                          size = 'md',
                          label = '',
                          hideLabel = false,
                      Severity: Minor
                      Found in apps/admin-x-design-system/src/global/Button.tsx - About 1 day 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

                      File StripeMigrations.js has 528 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      const _ = require('lodash');
                      const logging = require('@tryghost/logging');
                      
                      module.exports = class StripeMigrations {
                          /**
                      Severity: Major
                      Found in ghost/stripe/lib/StripeMigrations.js - About 1 day to fix

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

                        import {HumanReadableError} from './errors';
                        import {transformApiSiteData, transformApiTiersData, getUrlHistory} from './helpers';
                        
                        function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) {
                            const apiPath = 'members/api';
                        Severity: Major
                        Found in apps/portal/src/utils/api.js - About 1 day to fix
                          Severity
                          Category
                          Status
                          Source
                          Language