TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function handleObject has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        const handleObject = (obj, key) => {
            if (!Object.prototype.hasOwnProperty.call(obj, key)) {
                return;
            }

Severity: Major
Found in ghost/core/core/server/data/importer/importers/data/Base.js - About 2 hrs to fix

    Function handleError has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        handleError(errs, obj) {
            let errorsToReject = [];
            let problems = [];
    
            // CASE: validation errors, see models/base/events.js onValidate
    Severity: Major
    Found in ghost/core/core/server/data/importer/importers/data/Base.js - About 2 hrs to fix

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

      module.exports = createTransactionalMigration(async function up(knex) {
          // eslint-disable-next-line no-restricted-syntax
          const compedMemberIds = (await knex('members')
              .select('members.id')
              .innerJoin(

        Function viteConfig has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default (function viteConfig() {
            return defineConfig({
                logLevel: process.env.CI ? 'info' : 'warn',
                plugins: [
                    svgr(),
        Severity: Major
        Found in apps/comments-ui/vite.config.ts - About 2 hrs to fix

          File gh-uploader.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import Component from '@ember/component';
          import EmberObject, {get} from '@ember/object';
          import classic from 'ember-classic-decorator';
          import ghostPaths from 'ghost-admin/utils/ghost-paths';
          import {
          Severity: Minor
          Found in ghost/admin/app/components/gh-uploader.js - About 2 hrs to fix

            File Base.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            const debug = require('@tryghost/debug')('importer:base');
            const _ = require('lodash');
            const ObjectId = require('bson-objectid').default;
            const errors = require('@tryghost/errors');
            const {sequence} = require('@tryghost/promise');
            Severity: Minor
            Found in ghost/core/core/server/data/importer/importers/data/Base.js - About 2 hrs to fix

              File routes.js has 257 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              const express = require('../../../../../shared/express');
              const api = require('../../../../api').endpoints;
              const {http} = require('@tryghost/api-framework');
              const apiMw = require('../../middleware');
              const mw = require('./middleware');
              Severity: Minor
              Found in ghost/core/core/server/web/api/endpoints/admin/routes.js - About 2 hrs to fix

                File ImageSize.js has 257 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                const debug = require('@tryghost/debug')('utils:image-size');
                const sizeOf = require('image-size');
                
                const url = require('url');
                const path = require('path');
                Severity: Minor
                Found in ghost/core/core/server/lib/image/ImageSize.js - About 2 hrs to fix

                  ImportManager has 21 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class ImportManager {
                      constructor() {
                          const mediaHandler = new ImporterContentFileHandler({
                              type: 'media',
                              // @NOTE: making the second parameter strict folder "content/media" brakes the glob pattern
                  Severity: Minor
                  Found in ghost/core/core/server/data/importer/import-manager.js - About 2 hrs to fix

                    Function mockUsers has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function mockUsers(server) {
                        // /users/me = Always return the user with ID=1
                        server.get('/users/me/', function ({users}) {
                            let user = users.find(1);
                    
                    
                    Severity: Major
                    Found in ghost/admin/mirage/config/users.js - About 2 hrs to fix

                      Function generateSlug has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              generateSlug: function generateSlug(Model, base, options) {
                                  let slug;
                                  let slugTryCount = 1;
                                  const baseName = Model.prototype.tableName.replace(/s$/, '');
                      
                      
                      Severity: Major
                      Found in ghost/core/core/server/models/base/plugins/generate-slug.js - About 2 hrs to fix

                        Function _onResourceUpdated has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            async _onResourceUpdated(type, model) {
                                debug('_onResourceUpdated', type);
                        
                                const resourceConfig = _.find(this.resourcesConfig, {type: type});
                        
                        
                        Severity: Major
                        Found in ghost/core/core/server/services/url/Resources.js - About 2 hrs to fix

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

                          module.exports = async function (options) {
                              const hasFilter = options.limit !== 'all' || options.filter || options.search;
                          
                              let ids = null;
                              if (hasFilter) {
                          Severity: Major
                          Found in ghost/core/core/server/services/members/exporter/query.js - About 2 hrs to fix

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

                                async function up(knex) {
                                    const badVersionUsedFor40Migration = await knex('migrations')
                                        .where({
                                            name: '18-transform-urls-absolute-to-transform-ready.js'
                                        })

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

                                  async function up(knex) {
                                      logging.info('Updating members.status based on members_stripe_customers_subscriptions.status');
                                      // eslint-disable-next-line no-restricted-syntax
                                      const paidMemberIds = (await knex('members')
                                          .select('members.id')

                                Function createPublicFileMiddleware has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function createPublicFileMiddleware(location, file, mime, maxAge, options = {}) {
                                    let cache;
                                    // These files are provided by Ghost, and therefore live inside of the core folder
                                    const staticFilePath = config.get('paths').publicFilePath;
                                    // These files are built on the fly, and must be saved in the content folder
                                Severity: Major
                                Found in ghost/core/core/frontend/web/middleware/serve-public-file.js - About 2 hrs to fix

                                  File Resources.js has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                                  Open

                                  const _ = require('lodash');
                                  const debug = require('@tryghost/debug')('services:url:resources');
                                  const DomainEvents = require('@tryghost/domain-events');
                                  const {URLResourceUpdatedEvent} = require('@tryghost/dynamic-routing-events');
                                  const Resource = require('./Resource');
                                  Severity: Minor
                                  Found in ghost/core/core/server/services/url/Resources.js - About 2 hrs to fix

                                    File ghost_head.js has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                                    Open

                                    // # Ghost Head Helper
                                    // Usage: `{{ghost_head}}`
                                    //
                                    // Outputs scripts and other assets at the top of a Ghost theme
                                    const {labs, metaData, settingsCache, config, blogIcon, urlUtils, getFrontendKey} = require('../services/proxy');
                                    Severity: Minor
                                    Found in ghost/core/core/frontend/helpers/ghost_head.js - About 2 hrs to fix

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

                                          async function up(knex) {
                                              // eslint-disable-next-line no-restricted-syntax
                                              const canceledSubscriptions = await knex('members_stripe_customers_subscriptions')
                                                  .select(
                                                      'members_stripe_customers_subscriptions.id',

                                        Function EmailSuppressedPage has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                        export default function EmailSuppressedPage() {
                                            const {brandColor, lastPage, onAction, action, site, t} = useContext(AppContext);
                                        
                                            useEffect(() => {
                                                if (['removeEmailFromSuppressionList:success'].includes(action)) {
                                        Severity: Major
                                        Found in apps/portal/src/components/pages/EmailSuppressedPage.js - About 2 hrs to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language