TryGhost/Ghost

View on GitHub

Showing 1,756 of 3,886 total issues

`` has 37 functions (exceeds 20 allowed). Consider refactoring.
Open

Post = ghostBookshelf.Model.extend({

    tableName: 'posts',

    actionsCollectCRUD: true,
Severity: Minor
Found in ghost/core/core/server/models/post.js - About 4 hrs to fix

    Function updateSubscription has 119 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async updateSubscription(req, res) {
            try {
                const identity = req.body.identity;
                const subscriptionId = req.params.id;
                const cancelAtPeriodEnd = req.body.cancel_at_period_end;
    Severity: Major
    Found in ghost/members-api/lib/controllers/MemberController.js - About 4 hrs to fix

      Function handleAudioPlayer has 119 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const handleAudioPlayer = function (audioElementContainer) {
              const audioPlayerContainer = audioElementContainer.querySelector('.kg-audio-player-container');
              const playIconContainer = audioElementContainer.querySelector('.kg-audio-play-icon');
              const pauseIconContainer = audioElementContainer.querySelector('.kg-audio-pause-icon');
              const seekSlider = audioElementContainer.querySelector('.kg-audio-seek-slider');
      Severity: Major
      Found in ghost/core/core/frontend/src/cards/js/audio.js - About 4 hrs to fix

        Function create has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

            async create(data, options) {
                if (!options) {
                    options = {};
                }
        
        
        Severity: Minor
        Found in ghost/members-api/lib/repositories/MemberRepository.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 Connect has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

        const Connect: React.FC = () => {
            const [submitEnabled, setSubmitEnabled] = useState(false);
            const [token, setToken] = useState('');
            const [testMode, setTestMode] = useState(false);
            const [error, setError] = useState('');

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

        _private.validateData = function validateData(object) {
            if (!Object.prototype.hasOwnProperty.call(object, 'data')) {
                return object;
            }
        
        
        Severity: Major
        Found in ghost/core/core/server/services/route-settings/validate.js - About 4 hrs to fix

          File PaymentsService.js has 361 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          const logging = require('@tryghost/logging');
          const DomainEvents = require('@tryghost/domain-events');
          const {TierCreatedEvent, TierPriceChangeEvent, TierNameChangeEvent} = require('@tryghost/tiers');
          const OfferCreatedEvent = require('@tryghost/members-offers').events.OfferCreatedEvent;
          const {BadRequestError} = require('@tryghost/errors');
          Severity: Minor
          Found in ghost/payments/lib/PaymentsService.js - About 4 hrs to fix

            Function edit has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
            Open

                edit: function (data, unfilteredOptions) {
                    const options = this.filterOptions(unfilteredOptions, 'edit');
                    const self = this;
            
                    if (!Array.isArray(data)) {
            Severity: Minor
            Found in ghost/core/core/server/models/settings.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 deliverActivity has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
            Open

                async deliverActivity(activity: Activity, actor: Actor): Promise<void> {
                    const recipients = await this.getRecipients(activity);
                    for (const recipient of recipients) {
                        const data = await this.fetchForActor(recipient.href, actor);
                        if ('inbox' in data && typeof data.inbox === 'string') {
            Severity: Minor
            Found in ghost/ghost/src/core/activitypub/tell-the-world.service.ts - 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 DesignModal has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
            Open

            const DesignModal: React.FC = () => {
                const {settings, siteData} = useGlobalData();
                const {mutateAsync: editSettings} = useEditSettings();
                const {data: {posts: [latestPost]} = {posts: []}} = useBrowsePosts({
                    searchParams: {
            Severity: Minor
            Found in apps/admin-x-settings/src/components/settings/site/DesignModal.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 ImageUpload has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
            Open

            const ImageUpload: React.FC<ImageUploadProps> = ({
                id,
                children,
                width = '100%',
                height = '120px',
            Severity: Minor
            Found in apps/admin-x-design-system/src/global/form/ImageUpload.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 init has 114 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

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

                  init() {
                      if (this.repository) {
                          return;
                      }
              
              

                Function doImport has 112 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    doImport: async function doImport(importData, importOptions) {
                        debug('doImport');
                        importOptions = importOptions || {};
                
                        if (importOptions.importTag && importData?.data?.posts) {
                Severity: Major
                Found in ghost/core/core/server/data/importer/importers/data/data-importer.js - About 4 hrs to fix

                  Function OfferPageStyles has 112 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const OfferPageStyles = () => {
                      return `
                  .gh-portal-offer {
                      padding-bottom: 0;
                      overflow: unset;
                  Severity: Major
                  Found in apps/portal/src/components/pages/OfferPage.js - About 4 hrs to fix

                    Function exports has 111 lines of code (exceeds 25 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;

                      Function beforeImport has 111 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          beforeImport() {
                              debug('beforeImport');
                      
                              const activeTheme = _.find(this.dataToImport, {key: 'active_theme'});
                      
                      

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

                            async sendMagicLink(req, res) {
                                const {email, autoRedirect} = req.body;
                                let {emailType, redirect} = req.body;
                        
                                let referer = req.get('referer');
                        Severity: Minor
                        Found in ghost/members-api/lib/controllers/RouterController.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 foreach has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                        Open

                        module.exports = function foreach(items, options) {
                            if (!options) {
                                logging.warn(tpl(messages.iteratorNeeded));
                            }
                        
                        
                        Severity: Minor
                        Found in ghost/core/core/frontend/helpers/foreach.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 updateProfile has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
                        Open

                        async function updateProfile({data, state, api}) {
                            const [dataUpdate, emailUpdate] = await Promise.all([updateMemberData({data, state, api}), updateMemberEmail({data, state, api})]);
                            if (dataUpdate && emailUpdate) {
                                if (emailUpdate.success) {
                                    return {
                        Severity: Minor
                        Found in apps/portal/src/actions.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

                        Severity
                        Category
                        Status
                        Source
                        Language