TryGhost/Ghost

View on GitHub

Showing 1,747 of 3,879 total issues

Function mockMembers has 216 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function mockMembers(server) {
    server.post('/members/', withPermissionsCheck(ALLOWED_ROLES, function ({members}) {
        const attrs = this.normalizedRequestAttrs();
        return members.create(attrs);
    }));
Severity: Major
Found in ghost/admin/mirage/config/members.js - About 1 day to fix

    File actions.js has 526 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import setupGhostApi from './utils/api';
    import {HumanReadableError} from './utils/errors';
    import {createPopupNotification, getMemberEmail, getMemberName, getProductCadenceFromPrice, removePortalLinkFromUrl, getRefDomain} from './utils/helpers';
    
    function switchPage({data, state}) {
    Severity: Major
    Found in apps/portal/src/actions.js - About 1 day to fix

      File CollectionsService.ts has 516 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import logging from '@tryghost/logging';
      import tpl from '@tryghost/tpl';
      import isEqual from 'lodash/isEqual';
      import {Knex} from 'knex';
      import {
      Severity: Major
      Found in ghost/collections/src/CollectionsService.ts - About 1 day to fix

        Function update has 209 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async update(data, options) {
                const sharedOptions = {
                    transacting: options.transacting
                };
        
        
        Severity: Major
        Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 day to fix

          Function draw has a Cognitive Complexity of 51 (exceeds 5 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: Minor
          Found in ghost/admin/app/components/dashboard/charts/paid-mix.js - About 7 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 handleVideoPlayer has 197 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              const handleVideoPlayer = function (videoElementContainer) {
                  const videoPlayer = videoElementContainer.querySelector('.kg-video-player');
                  const videoPlayerContainer = videoElementContainer.querySelector('.kg-video-player-container');
                  const playIconContainer = videoElementContainer.querySelector('.kg-video-play-icon');
                  const pauseIconContainer = videoElementContainer.querySelector('.kg-video-pause-icon');
          Severity: Major
          Found in ghost/core/core/frontend/src/cards/js/video.js - About 7 hrs to fix

            Function UnsubscribePage has 197 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function UnsubscribePage() {
                const {site, api, pageData, member: loggedInMember, onAction, t} = useContext(AppContext);
                // member is the member data fetched from the API based on the uuid and its state is limited to just this modal, not all of Portal
                const [member, setMember] = useState();
                const [loading, setLoading] = useState(true);
            Severity: Major
            Found in apps/portal/src/components/pages/UnsubscribePage.js - About 7 hrs to fix

              Function InviteUserModal has 194 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const InviteUserModal = NiceModal.create(() => {
                  const modal = NiceModal.useModal();
                  const rolesQuery = useBrowseRoles();
                  const assignableRolesQuery = useBrowseRoles({
                      searchParams: {limit: 'all', permissions: 'assign'}

                Function milestoneEmailConfig has 192 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const milestoneEmailConfig = (siteTitle, formattedValue) => {
                    const arrContent = {
                        subject: `${siteTitle} hit ${formattedValue} ARR`,
                        heading: `Congrats! You reached ${formattedValue} ARR`,
                        content: [
                Severity: Major
                Found in ghost/staff-service/lib/milestone-email-config.js - About 7 hrs to fix

                  File ProductRepository.js has 486 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  const {UpdateCollisionError, NotFoundError, MethodNotAllowedError, ValidationError, BadRequestError} = require('@tryghost/errors');
                  const tpl = require('@tryghost/tpl');
                  
                  const messages = {
                      priceMustBeInteger: 'Tier prices must be an integer.',
                  Severity: Minor
                  Found in ghost/members-api/lib/repositories/ProductRepository.js - About 7 hrs to fix

                    File gh-post-settings-menu.js has 472 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import Component from '@ember/component';
                    import boundOneWay from 'ghost-admin/utils/bound-one-way';
                    import classic from 'ember-classic-decorator';
                    import moment from 'moment-timezone';
                    import {action, computed} from '@ember/object';
                    Severity: Minor
                    Found in ghost/admin/app/components/gh-post-settings-menu.js - About 7 hrs to fix

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

                      // NOTE: We must not cache references to membersService.api
                      // as it is a getter and may change during runtime.
                      const moment = require('moment-timezone');
                      const errors = require('@tryghost/errors');
                      const models = require('../../models');
                      Severity: Minor
                      Found in ghost/core/core/server/api/endpoints/members.js - About 7 hrs to fix

                        Function OffersIndexModal has 182 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export const OffersIndexModal = () => {
                            const modal = useModal();
                            const {updateRoute} = useRouting();
                            const {data: {offers: allOffers = []} = {}, isFetching: isFetchingOffers} = useBrowseOffers({
                                searchParams: {

                          Function exports has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
                          Open

                          module.exports = async (model, frame, options = {}) => {
                              const {tiers: tiersData} = options || {};
                          
                              // NOTE: `model` is now overloaded and may be a bookshelf model or a POJO
                              let jsonModel = model;

                          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 a Cognitive Complexity of 47 (exceeds 5 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: Minor
                          Found in ghost/core/core/frontend/helpers/ghost_head.js - About 7 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 AddDetailsPopup has 179 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const AddDetailsPopup = (props: Props) => {
                              const inputNameRef = useRef<HTMLInputElement>(null);
                              const inputExpertiseRef = useRef<HTMLInputElement>(null);
                              const {dispatchAction, member, accentColor, t} = useAppContext();
                          
                          
                          Severity: Major
                          Found in apps/comments-ui/src/components/popups/AddDetailsPopup.tsx - About 7 hrs to fix

                            Function exports has a Cognitive Complexity of 46 (exceeds 5 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: Minor
                            Found in ghost/core/core/server/models/base/plugins/actions.js - About 7 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

                            File ThemeModal.tsx has 460 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import AdvancedThemeSettings from './theme/AdvancedThemeSettings';
                            import InvalidThemeModal, {FatalErrors} from './theme/InvalidThemeModal';
                            import NiceModal, {NiceModalHandler, useModal} from '@ebay/nice-modal-react';
                            import OfficialThemes from './theme/OfficialThemes';
                            import React, {useEffect, useState} from 'react';
                            Severity: Minor
                            Found in apps/admin-x-settings/src/components/settings/site/ThemeModal.tsx - About 7 hrs to fix

                              Function usePinturaEditor has 169 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export default function usePinturaEditor() {
                                  const {config: globalConfig, settings} = useGlobalData() as { config: Config, settings: Setting[] };
                                  const [pintura] = getSettingValues<boolean>(settings, ['pintura']);
                                  const [scriptLoaded, setScriptLoaded] = useState<boolean>(false);
                                  const [cssLoaded, setCssLoaded] = useState<boolean>(false);
                              Severity: Major
                              Found in apps/admin-x-settings/src/hooks/usePinturaEditor.ts - About 6 hrs to fix

                                Function getDescription has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
                                Open

                                function getDescription(data, root, options = {}) {
                                    const context = root ? root.context : null;
                                
                                    let description = '';
                                
                                
                                Severity: Minor
                                Found in ghost/core/core/frontend/meta/description.js - About 6 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

                                Severity
                                Category
                                Status
                                Source
                                Language