TryGhost/Ghost

View on GitHub

Showing 1,756 of 3,886 total issues

Function OffersIndexModal has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

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

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 ThemeToolbar has a Cognitive Complexity of 40 (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 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

File fixtures-generator.js has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable camelcase */

export const sites = {
    singleProduct: getSiteData({
        products: getProductsData({numOfProducts: 1})
Severity: Minor
Found in apps/portal/src/utils/fixtures-generator.js - About 6 hrs to fix

    File paid-mix.js has 415 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* globals Chart */
    
    import Component from '@glimmer/component';
    import {action} from '@ember/object';
    import {inject as service} from '@ember/service';
    Severity: Minor
    Found in ghost/admin/app/components/dashboard/charts/paid-mix.js - About 5 hrs to fix

      Function fetchAll has 148 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                  fetchAll: function (options) {
                      options = options || {};
      
                      const nql = require('@tryghost/nql');
                      const modelName = options.modelName;
      Severity: Major
      Found in ghost/core/core/server/models/base/plugins/raw-knex.js - About 5 hrs to fix

        Function validateSchema has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
        Open

        function validateSchema(tableName, model, options) {
            options = options || {};
        
            const columns = _.keys(schema[tableName]);
            let validationErrors = [];
        Severity: Minor
        Found in ghost/core/core/server/data/schema/validator.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 PaidAccountActions has 147 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const PaidAccountActions = () => {
            const {member, site, onAction, t} = useContext(AppContext);
        
            const onEditBilling = () => {
                const subscription = getMemberSubscription({member});

          Function PortalModal has 147 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const PortalModal: React.FC = () => {
              const {updateRoute} = useRouting();
          
              const [selectedPreviewTab, setSelectedPreviewTab] = useState('signup');
          
          

            Function DesignModal has 146 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const DesignModal: React.FC = () => {
                const {settings, siteData} = useGlobalData();
                const {mutateAsync: editSettings} = useEditSettings();
                const {data: {posts: [latestPost]} = {posts: []}} = useBrowsePosts({
                    searchParams: {
            Severity: Major
            Found in apps/admin-x-settings/src/components/settings/site/DesignModal.tsx - About 5 hrs to fix

              Function Sidebar has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
              Open

              }> = ({newsletter, onlyOne, updateNewsletter, validate, errors, clearError}) => {
                  const {updateRoute} = useRouting();
                  const {mutateAsync: editNewsletter} = useEditNewsletter();
                  const limiter = useLimiter();
                  const {settings, siteData, config} = useGlobalData();

              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 StaffServiceEmails.js has 400 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              const {promises: fs, readFileSync} = require('fs');
              const path = require('path');
              const moment = require('moment');
              const glob = require('glob');
              const {EmailAddressParser} = require('@tryghost/email-addresses');
              Severity: Minor
              Found in ghost/staff-service/lib/StaffServiceEmails.js - About 5 hrs to fix

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

                    getAction(event, hasMultipleNewsletters) {
                        if (event.type === 'signup_event' || (event.type === 'subscription_event' && event.data.type === 'created' && event.data.signup)) {
                            return 'signed up';
                        }
                
                
                Severity: Minor
                Found in ghost/admin/app/helpers/parse-member-event.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 exports has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports = function (Bookshelf) {
                    Bookshelf.Model = Bookshelf.Model.extend({
                        // When loading an instance, subclasses can specify default to fetch
                        defaultColumnsToFetch: function defaultColumnsToFetch() {
                            return [];
                Severity: Minor
                Found in ghost/core/core/server/models/base/plugins/crud.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 MembersAPI has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports = function MembersAPI({
                    tokenConfig: {
                        issuer,
                        privateKey,
                        publicKey
                Severity: Minor
                Found in ghost/members-api/lib/members-api.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 prepAttrsForEmailVerification has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                Open

                    async prepAttrsForEmailVerification(attrs, newsletter) {
                        const cleanedAttrs = _.cloneDeep(attrs);
                        const emailsToVerify = [];
                        const emailProperties = [
                            {property: 'sender_email', type: 'from', emptyable: true, error: messages.senderEmailNotAllowed}
                Severity: Minor
                Found in ghost/core/core/server/services/newsletters/NewslettersService.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 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 boot.js has 398 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    // The Ghost Boot Sequence
                    // -----------------------
                    // - This is intentionally one big file at the moment, so that we don't have to follow boot logic all over the place
                    // - This file is FULL of debug statements so we can see timings for the various steps because the boot needs to be as fast as possible
                    // - As we manage to break the codebase down into distinct components for e.g. the frontend, their boot logic can be offloaded to them
                    Severity: Minor
                    Found in ghost/core/core/boot.js - 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

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

                        module.exports = function (Bookshelf) {
                            Bookshelf.Model = Bookshelf.Model.extend({
                                // When loading an instance, subclasses can specify default to fetch
                                defaultColumnsToFetch: function defaultColumnsToFetch() {
                                    return [];
                        Severity: Major
                        Found in ghost/core/core/server/models/base/plugins/crud.js - About 5 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language