TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function createCheckoutSession has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async createCheckoutSession(req, res) {
        const type = req.body.type ?? 'subscription';
        const metadata = req.body.metadata ?? {};
        const identity = req.body.identity;
        const membersEnabled = true;
Severity: Major
Found in ghost/members-api/lib/controllers/RouterController.js - About 2 hrs to fix

    Function onSaving has 65 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        onSaving: function onSaving(newPage, attr, options) {
            const self = this;
            const tasks = [];
            let passwordValidation = {};
    
    
    Severity: Major
    Found in ghost/core/core/server/models/user.js - About 2 hrs to fix

      Function ping has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function ping(post) {
          let pingXML;
          const title = post.title;
          const url = urlService.getUrlByResourceId(post.id, {absolute: true});
      
      
      Severity: Major
      Found in ghost/core/core/server/services/xmlrpc.js - About 2 hrs to fix

        Function apiKeyAuthenticateWithToken has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const authenticateWithToken = async function apiKeyAuthenticateWithToken(originalUrl, token, ignoreMaxAge) {
            const decoded = jwt.decode(token, {complete: true});
            const jwtValidationOptions = ignoreMaxAge ? _.omit(JWT_OPTIONS_DEFAULTS, 'maxAge') : JWT_OPTIONS_DEFAULTS;
        
            if (!decoded || !decoded.header) {
        Severity: Major
        Found in ghost/core/core/server/services/auth/api-key/admin.js - About 2 hrs to fix

          Function createCustomNotification has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              async createCustomNotification(notification) {
                  if (!notification || !notification.messages || notification.messages.length === 0) {
                      debug(`Skipping notification creation as there are no messages to process`);
                      return;
                  }
          Severity: Minor
          Found in ghost/update-check-service/lib/UpdateCheckService.js - About 2 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 a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              async init() {
                  this.Suppression = models.Suppression;
                  const handleEvent = reason => async (event) => {
                      try {
                          if (reason === 'bounce') {

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

          function addTableColumn(tableName, tableBuilder, columnName, columnSpec = schema[tableName][columnName]) {
              let column;
          
              // creation distinguishes between text with fieldtype, string with maxlength and all others
              if (columnSpec.type === 'text' && Object.prototype.hasOwnProperty.call(columnSpec, 'fieldtype')) {
          Severity: Minor
          Found in ghost/core/core/server/data/schema/commands.js - About 2 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 fetchOembedData has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              async fetchOembedData(url, html, cardType) {
                  // Lazy require the library to keep boot quick
                  const cheerio = require('cheerio');
          
                  // check for <link rel="alternate" type="application/json+oembed"> element
          Severity: Minor
          Found in ghost/oembed-service/lib/OEmbedService.js - About 2 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 useNavigationEditor has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          const useNavigationEditor = ({items, setItems}: {
              items: NavigationItem[];
              setItems: (newItems: NavigationItem[]) => void;
          }): NavigationEditor => {
              const hasNewItem = (newItem: NavigationItem) => Boolean((newItem.label && !newItem.label.match(/^\s*$/)) || newItem.url !== '/');
          Severity: Minor
          Found in apps/admin-x-settings/src/hooks/site/useNavigationEditor.tsx - About 2 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 TextField has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

          const TextField: React.FC<TextFieldProps> = ({
              type = 'text',
              inputRef,
              title,
              hideTitle,
          Severity: Minor
          Found in apps/admin-x-design-system/src/global/form/TextField.tsx - About 2 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 paid-breakdown.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

            Function populateMembersMonthlyPriceIdSettings has 64 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async populateMembersMonthlyPriceIdSettings(options) {
                    if (!options) {
                        return this.models.Product.transaction((transacting) => {
                            return this.populateMembersMonthlyPriceIdSettings({transacting});
                        });
            Severity: Major
            Found in ghost/stripe/lib/StripeMigrations.js - About 2 hrs to fix

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

                  async updateSubscription(data, options) {
                      const sharedOptions = {
                          transacting: options ? options.transacting : null
                      };
                      if (!this._stripeAPIService.configured) {
              Severity: Major
              Found in ghost/members-api/lib/repositories/MemberRepository.js - About 2 hrs to fix

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

                module.exports = createIrreversibleMigration(async (knex) => {
                    if (!DatabaseInfo.isSQLite(knex)) {
                        return logging.warn('Skipping adding "on delete cascade" - database is not SQLite3');
                    }
                
                

                  Function useDefaultRecipientsOptions has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const useDefaultRecipientsOptions = (selectedOption: string, defaultEmailRecipientsFilter?: string | null) => {
                      const tiers = useFilterableApi<Tier, 'tiers', 'name'>({path: '/tiers/', filterKey: 'name', responseKey: 'tiers'});
                      const labels = useFilterableApi<Label, 'labels', 'name'>({path: '/labels/', filterKey: 'name', responseKey: 'labels'});
                      const offers = useFilterableApi<Offer, 'offers', 'name'>({path: '/offers/', filterKey: 'name', responseKey: 'offers'});
                  
                  

                    File NewsletterPreviewContent.tsx has 273 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import CoverImage from '../../../../assets/images/user-cover.png';
                    import LatestPosts1 from '../../../../assets/images/latest-posts-1.png';
                    import LatestPosts2 from '../../../../assets/images/latest-posts-2.png';
                    import LatestPosts3 from '../../../../assets/images/latest-posts-3.png';
                    import clsx from 'clsx';

                      Function result has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          const result = keys.reduce((obj, method) => {
                              const apiImpl = _.cloneDeep(apiController)[method];
                      
                              Object.freeze(apiImpl.headers);
                      
                      
                      Severity: Major
                      Found in ghost/api-framework/lib/pipeline.js - About 2 hrs to fix

                        Function populateMembersYearlyPriceIdSettings has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            async populateMembersYearlyPriceIdSettings(options) {
                                if (!options) {
                                    return this.models.Product.transaction((transacting) => {
                                        return this.populateMembersYearlyPriceIdSettings({transacting});
                                    });
                        Severity: Major
                        Found in ghost/stripe/lib/StripeMigrations.js - About 2 hrs to fix

                          Function getEventTimeline has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              async getEventTimeline(options = {}) {
                                  if (!options.limit) {
                                      options.limit = 10;
                                  }
                          
                          
                          Severity: Major
                          Found in ghost/members-api/lib/repositories/EventRepository.js - About 2 hrs to fix

                            Function add has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                add(apiConfig, frame, options = {add: true}) {
                                    debug('add');
                            
                                    if (_.get(frame,'options.source')) {
                                        const html = frame.data.pages[0].html;
                            Severity: Major
                            Found in ghost/core/core/server/api/endpoints/utils/serializers/input/pages.js - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language