TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function forPost has 52 lines of code (exceeds 25 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')) {

    Function validate has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async validate(token, options = {}) {
            if (!options.transacting) {
                return await this.model.transaction((transacting) => {
                    return this.validate(token, {
                        ...options,
    Severity: Major
    Found in ghost/core/core/server/services/members/SingleUseTokenProvider.js - About 2 hrs to fix

      Function doReset has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function doReset(options, tokenParts, settingsAPI) {
          let dbHash;
      
          const data = options.data.password_reset[0];
          const resetToken = data.token;
      Severity: Major
      Found in ghost/core/core/server/services/auth/passwordreset.js - About 2 hrs to fix

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

            async function up(connection) {
                const currentSetting = await connection('settings')
                    .where({key: 'members_signup_access'})
                    .select('value')
                    .first();

          Function allEvents has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  const allEvents = allSubscriptions.reduce((allEventsAcc, subscription) => {
                      if (['incomplete', 'incomplete_expired'].includes(subscription.status)) {
                          return allEventsAcc;
                      }
          
          

            Function navigation has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function navigation(options) {
                options = options || {};
                options.hash = options.hash || {};
                options.data = options.data || {};
            
            
            Severity: Major
            Found in ghost/core/core/frontend/helpers/navigation.js - About 2 hrs to fix

              Function handle has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async handle(argv = {}) {
                      const _ = require('lodash');
                      // knex has to be loaded _after_ the call to setup()
                      // the db connection requires nconf which passes argv to yargs,
                      // which intercepts --help and stops execution
              Severity: Major
              Found in ghost/core/core/cli/timetravel.js - About 2 hrs to fix

                Function confirmStatusChange has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    const confirmStatusChange = async () => {
                        if (newsletter.status === 'active') {
                            NiceModal.show(ConfirmationModal, {
                                title: 'Archive newsletter',
                                prompt: <>

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

                  import Component from '@ember/component';
                  import ghostPaths from 'ghost-admin/utils/ghost-paths';
                  import {GENERIC_ERROR_MESSAGE} from 'ghost-admin/services/notifications';
                  import {
                      UnsupportedMediaTypeError,
                  Severity: Minor
                  Found in ghost/admin/app/components/gh-image-uploader.js - About 2 hrs to fix

                    Function generateMonochromePalette has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function generateMonochromePalette(baseColor, count = 10) {
                        // Convert hex to RGB
                        let r = parseInt(baseColor.slice(1, 3), 16);
                        let g = parseInt(baseColor.slice(3, 5), 16);
                        let b = parseInt(baseColor.slice(5, 7), 16);
                    Severity: Major
                    Found in ghost/admin/app/utils/stats.js - About 2 hrs to fix

                      Function browse has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          async browse(options) {
                              const defaultWithRelated = [
                                  'labels',
                                  'stripeSubscriptions',
                                  'stripeSubscriptions.customer',
                      Severity: Major
                      Found in ghost/members-api/lib/services/MemberBREADService.js - About 2 hrs to fix

                        Function bulkEdit has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            async bulkEdit(data, options) {
                                const {all, filter, search} = options;
                        
                                if (!['unsubscribe', 'addLabel', 'removeLabel'].includes(data.action)) {
                                    throw new errors.IncorrectUsageError({
                        Severity: Major
                        Found in ghost/members-api/lib/repositories/MemberRepository.js - About 2 hrs to fix

                          Function connect has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  const connect = (options = {}) => {
                                      let wasResolved = false;
                          
                                      const waitTimeout = setTimeout(() => {
                                          logging.info('Bootstrap socket timed out.');
                          Severity: Major
                          Found in ghost/bootstrap-socket/lib/bootstrap-socket.js - About 2 hrs to fix

                            Function onUpdated has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                onUpdated: function onUpdated(model, options) {
                                    ghostBookshelf.Model.prototype.onUpdated.apply(this, arguments);
                            
                                    model.statusChanging = model.get('status') !== model.previous('status');
                                    model.isPublished = model.get('status') === 'published';
                            Severity: Major
                            Found in ghost/core/core/server/models/post.js - About 2 hrs to fix

                              Function revertPortalPlansSetting has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

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

                                Function formatOnWrite has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    formatOnWrite(attrs) {
                                        // Ensure all URLs are stored as transform-ready with __GHOST_URL__ representing config.url
                                        const urlTransformMap = {
                                            mobiledoc: {
                                                method: 'mobiledocToTransformReady',
                                Severity: Major
                                Found in ghost/core/core/server/models/post.js - About 2 hrs to fix

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

                                      add: function add(dataToClone, unfilteredOptions) {
                                          const options = this.filterOptions(unfilteredOptions, 'add');
                                          const self = this;
                                          const data = _.cloneDeep(dataToClone);
                                          let userData = this.filterData(data);
                                  Severity: Major
                                  Found in ghost/core/core/server/models/user.js - About 2 hrs to fix

                                    Function transferOwnership has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        transferOwnership: function transferOwnership(object, unfilteredOptions) {
                                            const options = ghostBookshelf.Model.filterOptions(unfilteredOptions, 'transferOwnership');
                                            let ownerRole;
                                            let contextUser;
                                    
                                    
                                    Severity: Major
                                    Found in ghost/core/core/server/models/user.js - About 2 hrs to fix

                                      Function assignTagToUserPosts has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          async assignTagToUserPosts({id, context, transacting}) {
                                              // get author slug
                                              const author = await this.models.User.findOne({
                                                  id
                                              }, {
                                      Severity: Major
                                      Found in ghost/core/core/server/services/Users.js - About 2 hrs to fix

                                        Function domainEventDispatcher has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            domainEventDispatcher(modelEventName: string, data: any) {
                                                let event;
                                        
                                                switch (modelEventName) {
                                                case 'post.deleted':
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language