TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

File ThemeModal.tsx has 452 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 6 hrs to fix

    File fixtures-generator.js has 449 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

      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

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

        module.exports = function (Bookshelf) {
            Bookshelf.Model = Bookshelf.Model.extend({
                initializeEvents: function () {
                    // NOTE: triggered before `creating`/`updating`
                    this.on('saving', function onSaving(newObj, attrs, options) {
        Severity: Major
        Found in ghost/core/core/server/models/base/plugins/events.js - About 6 hrs to fix

          File helpers.test.js has 445 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import {getAllProductsForSite, getAvailableProducts, getCurrencySymbol, getFreeProduct, getMemberName, getMemberSubscription, getPriceFromSubscription, getPriceIdFromPageQuery, getSupportAddress, getDefaultNewsletterSender, getUrlHistory, hasMultipleProducts, isActiveOffer, isInviteOnlySite, isPaidMember, isSameCurrency, transformApiTiersData, isSigninAllowed, isSignupAllowed, getCompExpiry, isInThePast} from './helpers';
          import * as Fixtures from './fixtures-generator';
          import {site as FixturesSite, member as FixtureMember, offer as FixtureOffer, transformTierFixture as TransformFixtureTiers} from '../utils/test-fixtures';
          import {isComplimentaryMember} from '../utils/helpers';
          
          
          Severity: Minor
          Found in apps/portal/src/utils/helpers.test.js - About 6 hrs to fix

            File UserDetailModal.tsx has 443 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import ChangePasswordForm from './users/ChangePasswordForm';
            import EmailNotifications from './users/EmailNotifications';
            import NiceModal, {useModal} from '@ebay/nice-modal-react';
            import ProfileBasics from './users/ProfileBasics';
            import ProfileDetails from './users/ProfileDetails';

              Function SUBSCRIBED_FILTER has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
              Open

              export const SUBSCRIBED_FILTER = ({newsletters, group}) => {
                  return {
                      label: newsletters.length > 1 ? 'All newsletters' : 'Newsletter subscription',
                      name: 'subscribed',
                      columnLabel: 'Subscribed',
              Severity: Minor
              Found in ghost/admin/app/components/members/filters/subscribed.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

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

              module.exports = function (Bookshelf) {
                  Bookshelf.Model = Bookshelf.Model.extend({}, {
                      /**
                       * ### Generate Slug
                       * Create a string to act as the permalink for an object.
              Severity: Minor
              Found in ghost/core/core/server/models/base/plugins/generate-slug.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

              Function forPost has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports.forPost = (options, model, attrs) => {
                  const _ = require('lodash');
                  // This function is split up in 3 conditions for 3 different purposes:
                  // 1. Gets excerpt from post's plaintext. If custom_excerpt exists, it overrides the excerpt but the key remains excerpt.
                  if (Object.prototype.hasOwnProperty.call(options, 'columns') || _.includes(options.columns, 'excerpt') || _.includes(options.columns, 'excerpt') && options.formats && options.formats.includes('plaintext')) {

              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 43 (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 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

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

              module.exports = function (defaults) {
                  let app = new EmberApp(defaults, {
                      addons: {denylist},
                      babel: {
                          plugins: [
              Severity: Major
              Found in ghost/admin/ember-cli-build.js - About 6 hrs to fix

                Function createApiInstance has 163 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function createApiInstance(config) {
                    const membersApiInstance = MembersApi({
                        tokenConfig: config.getTokenConfig(),
                        auth: {
                            getSigninURL: config.getSigninURL.bind(config),
                Severity: Major
                Found in ghost/core/core/server/services/members/api.js - About 6 hrs to fix

                  File AccountPlanPage.js has 435 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import React, {useContext, useState} from 'react';
                  import AppContext from '../../AppContext';
                  import ActionButton from '../common/ActionButton';
                  import CloseButton from '../common/CloseButton';
                  import BackButton from '../common/BackButton';
                  Severity: Minor
                  Found in apps/portal/src/components/pages/AccountPlanPage.js - About 6 hrs to fix

                    Function generate has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
                    Open

                        generate() {
                            this.count += 1;
                    
                            const member = this.model;
                            const customer = this.membersStripeCustomers.get(this.model.id);

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

                    const Sidebar: React.FC = () => {
                        const {filter, setFilter, checkVisible, noResult, setNoResult} = useSearch();
                        const {updateRoute} = useRouting();
                        const searchInputRef = useRef<HTMLInputElement | null>(null);
                        const {isAnyTextFieldFocused} = useFocusContext();
                    Severity: Major
                    Found in apps/admin-x-settings/src/components/Sidebar.tsx - About 6 hrs to fix

                      Consider simplifying this complex logical expression.
                      Open

                          if (!unstyled) {
                              className = clsx(
                                  'inline-flex items-center justify-center whitespace-nowrap rounded text-sm transition',
                                  ((link && color !== 'clear' && color !== 'black') || (!link && color !== 'clear')) ? 'font-bold' : 'font-semibold',
                                  !link ? `${size === 'sm' ? 'h-7' : 'h-[34px]'}` : '',
                      Severity: Critical
                      Found in apps/admin-x-design-system/src/global/Button.tsx - About 6 hrs to fix

                        Function replaceIdentifiers has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
                        Open

                            replaceIdentifiers() {
                                const ownerUserId = _.find(this.requiredExistingData.users, (user) => {
                                    if (user.roles[0].name === 'Owner') {
                                        return true;
                                    }
                        Severity: Minor
                        Found in ghost/core/core/server/data/importer/importers/data/Base.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

                        Function PaidAccountActions has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
                        Open

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

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

                        const AddOfferModal = () => {
                            const {siteData} = useGlobalData();
                            const typeOptions = [
                                {title: 'Discount', description: 'Offer a special reduced price', value: 'percent'},
                                {title: 'Free trial', description: 'Give free access for a limited time', value: 'trial'}

                        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