TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function mockPages has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function mockPages(server) {
    server.post('/pages', function ({pages, users, tags}) {
        let attrs = this.normalizedRequestAttrs();

        attrs.authors = extractAuthors(attrs, users);
Severity: Minor
Found in ghost/admin/mirage/config/pages.js - About 1 hr to fix

    Function resourceNotFound has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports.resourceNotFound = function resourceNotFound(req, res, next) {
        if (req?.headers?.['accept-version'] && res.locals?.safeVersion) {
            // Protect against invalid `Accept-Version` headers
            const acceptVersionSemver = semver.coerce(req.headers['accept-version']);
            if (!acceptVersionSemver) {
    Severity: Minor
    Found in ghost/mw-error-handler/lib/mw-error-handler.js - About 1 hr to fix

      Function getSubscriptionHistory has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async getSubscriptionHistory() {
              const subscriptionDeltaEntries = await this.fetchAllSubscriptionDeltas();
              const counts = await this.fetchSubscriptionCounts();
      
              /** @type {Object.<string, Object.<string, number>>} */
      Severity: Minor
      Found in ghost/stats-service/lib/SubscriptionStatsService.js - About 1 hr to fix

        Function getPriceForDonations has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async getPriceForDonations() {
                const nickname = this.getDonationPriceNickname();
                const currency = this.settingsCache.get('donations_currency');
                const suggestedAmount = this.settingsCache.get('donations_suggested_amount');
        
        
        Severity: Minor
        Found in ghost/payments/lib/PaymentsService.js - About 1 hr to fix

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

              async onSaving(model, _attr, options) {
                  ghostBookshelf.Model.prototype.onSaving.apply(this, arguments);
          
                  if (model.get('name')) {
                      model.set('name', model.get('name').trim());
          Severity: Minor
          Found in ghost/core/core/server/models/product.js - About 1 hr to fix

            Function _createSubscriptionCheckoutSession has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async _createSubscriptionCheckoutSession(options) {
                    if (options.offer) {
                        // Attach offer information to stripe metadata for free trial offers
                        // free trial offers don't have associated stripe coupons
                        options.metadata.offer = options.offer.id;
            Severity: Minor
            Found in ghost/members-api/lib/controllers/RouterController.js - About 1 hr to fix

              Function all has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async all(models, apiConfig, frame) {
                      debug('all');
              
                      // CASE: e.g. destroy returns null
                      if (!models) {

                Function all has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    async all(models, apiConfig, frame) {
                        debug('all');
                
                        // CASE: e.g. destroy returns null
                        if (!models) {

                  Function setFromFilePath has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      async setFromFilePath(filePath) {
                          await this.createBackupFile(this.settingsPath, this.backupPath);
                          await this.saveFile(filePath, this.settingsPath);
                  
                          urlService.resetGenerators({releaseResourcesOnly: true});
                  Severity: Minor
                  Found in ghost/core/core/server/services/route-settings/RouteSettings.js - About 1 hr to fix

                    Function importFromFile has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        async importFromFile(file, importOptions = {}) {
                            let importData;
                            if (importOptions.data) {
                                importData = importOptions.data;
                            } else {
                    Severity: Minor
                    Found in ghost/core/core/server/data/importer/import-manager.js - About 1 hr to fix

                      Function up has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          async function up(knex) {
                              const products = await knex
                                  .select('id')
                                  .where({
                                      type: 'paid'

                        Function editBilling has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                async editBilling({successUrl, cancelUrl, subscriptionId} = {}) {
                                    const siteUrlObj = new URL(siteUrl);
                                    const identity = await api.member.identity();
                                    const url = endpointFor({type: 'members', resource: 'create-stripe-update-session'});
                                    if (!successUrl) {
                        Severity: Minor
                        Found in apps/portal/src/utils/api.js - About 1 hr to fix

                          Function StaffToken has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const StaffToken: React.FC = () => {
                              const {refetch: apiKey} = getStaffToken({
                                  enabled: false
                              });
                              const handleError = useHandleError();

                            Function FormPage has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export const FormPage: React.FC = () => {
                                const [error, setError] = React.useState('');
                                const [loading, setLoading] = React.useState(false);
                                const [success, setSuccess] = React.useState(false);
                                const {api, setPage, options, t} = useAppContext();
                            Severity: Minor
                            Found in apps/signup-form/src/components/pages/FormPage.tsx - About 1 hr to fix

                              Consider simplifying this complex logical expression.
                              Open

                                      if (options.property) {
                                          description = data.post[`${options.property}_description`]
                                              || data.post.custom_excerpt
                                              || data.post.meta_description
                                              || generateExcerpt(data.post.excerpt || '', {words: 50})
                              Severity: Critical
                              Found in ghost/core/core/frontend/meta/description.js - About 1 hr to fix

                                Consider simplifying this complex logical expression.
                                Open

                                        if (options.property) {
                                            description = data.page[`${options.property}_description`]
                                                || data.page.custom_excerpt
                                                || data.page.meta_description
                                                || generateExcerpt(data.page.excerpt || '', {words: 50})
                                Severity: Critical
                                Found in ghost/core/core/frontend/meta/description.js - About 1 hr to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                          if (options.property) {
                                              description = data.post[`${options.property}_description`]
                                                  || data.post.custom_excerpt
                                                  || data.post.meta_description
                                                  || generateExcerpt(data.post.excerpt || '', {words: 50})
                                  Severity: Critical
                                  Found in ghost/core/core/frontend/meta/description.js - About 1 hr to fix

                                    Function passwordValidation has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        passwordValidation(model, password, errorTarget) {
                                            let blogUrl = model.config?.blogUrl || window.location.host;
                                            let blogTitle = model.blogTitle || model.config?.blogTitle;
                                            let blogUrlWithSlash;
                                    
                                    
                                    Severity: Minor
                                    Found in ghost/admin/app/validators/mixins/password.js - About 1 hr to fix

                                      Function postBuild has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          postBuild: function (results) {
                                              const fs = this.project.require('fs-extra');
                                              const walkSync = this.project.require('walk-sync');
                                      
                                              const assetsOut = path.join(path.dirname(require.resolve('ghost')), `core/built/admin`);
                                      Severity: Minor
                                      Found in ghost/admin/lib/asset-delivery/index.js - About 1 hr to fix

                                        Function registerHelpers has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            registerHelpers(handlebars, labs) {
                                                handlebars.registerHelper('if', function (conditional, options) {
                                                    if (conditional) {
                                                        return options.fn(this);
                                                    } else {
                                        Severity: Minor
                                        Found in ghost/email-service/lib/helpers/register-helpers.js - About 1 hr to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language