TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function getCountHistory has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async getCountHistory() {
        const rows = await this.fetchAllStatusDeltas();

        // Fetch current total amounts and start counting from there
        const totals = await this.getCount();
Severity: Minor
Found in ghost/stats-service/lib/MembersStatsService.js - About 1 hr to fix

    Function matchAuthors has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            matchAuthors(model, options) {
                let ownerUser;
                const ops = [];
    
                ops.push(() => {
    Severity: Minor
    Found in ghost/core/core/server/models/relations/authors.js - About 1 hr to fix

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

          all(_apiConfig, frame) {
              if (frame.options.filter) {
                  try {
                      frame.options.filter = nql.parse(frame.options.filter);
                  } catch (err) {

        Function beginCheck has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            beginCheck(context) {
                const self = this;
                let userPermissionLoad;
                let apiKeyPermissionLoad;
                let memberPermissionLoad;
        Severity: Minor
        Found in ghost/core/core/server/services/permissions/can-this.js - About 1 hr to fix

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

              async function up(connection) {
                  const oldSetting = await connection('settings')
                      .where('key', 'newsletter_show_header')
                      .select(['value', 'created_by'])
                      .first();

            Function run has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    const run = (postToImport, postIndex, targetProperty, tableName) => {
                        if (!postToImport[targetProperty] || !postToImport[targetProperty].length) {
                            return;
                        }
            
            

              Function imgUrl has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = function imgUrl(requestedImageUrl, options) {
                  // CASE: if no url is passed, e.g. `{{img_url}}` we show a warning
                  if (arguments.length < 2) {
                      logging.warn(tpl(messages.attrIsRequired));
                      return;
              Severity: Minor
              Found in ghost/core/core/frontend/helpers/img_url.js - About 1 hr to fix

                Function fetchData has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function fetchData(pathOptions, routerOptions, locals) {
                    pathOptions = pathOptions || {};
                    routerOptions = routerOptions || {};
                
                    let postQuery = _.cloneDeep(defaultPostQuery);
                Severity: Minor
                Found in ghost/core/core/frontend/services/data/fetch-data.js - About 1 hr to fix

                  Function compare has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      compare: function compare(options) {
                          options = options || {};
                  
                          const tokenToCompare = options.token;
                          const parts = exports.resetToken.extract({token: tokenToCompare});
                  Severity: Minor
                  Found in ghost/security/lib/tokens.js - About 1 hr to fix

                    Function fetchPostsFromData has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const fetchPostsFromData = (revueData) => {
                        const itemData = JSON.parse(revueData.items);
                        const issueData = papaparse.parse(revueData.issues, {
                            header: true,
                            skipEmptyLines: true,
                    Severity: Minor
                    Found in ghost/importer-revue/lib/importer-revue.js - About 1 hr to fix

                      Function edit has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          async edit(data: any): Promise<CollectionDTO | null> {
                              return await this.collectionsRepository.createTransaction(async (transaction) => {
                                  const collection = await this.collectionsRepository.getById(data.id, {transaction});
                      
                                  if (!collection) {
                      Severity: Minor
                      Found in ghost/collections/src/CollectionsService.ts - About 1 hr to fix

                        Function _showAPIError has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            _showAPIError(resp, options) {
                                options = options || {};
                                options.type = options.type || 'error';
                        
                                // if possible use the title to get a unique key
                        Severity: Minor
                        Found in ghost/admin/app/services/notifications.js - About 1 hr to fix

                          Function prepareUserMessage has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const prepareUserMessage = function prepareUserMessage(err, req) {
                              const userError = {
                                  message: err.message,
                                  context: err.context
                              };
                          Severity: Minor
                          Found in ghost/mw-error-handler/lib/mw-error-handler.js - About 1 hr to fix

                            Function _syncRepositoryWithTheme has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                async _syncRepositoryWithTheme(name, theme) {
                                    const themeSettings = theme.customSettings || {};
                            
                                    const settingsCollection = await this._repository.browse({filter: `theme:'${name}'`});
                                    let knownSettings = settingsCollection.toJSON();

                              Function getAction has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      getAction(event, options) {
                                          const actor = this.getActor(options);
                              
                                          // @NOTE: we ignore internal updates (`options.context.internal`) for now
                                          if (!actor) {
                              Severity: Minor
                              Found in ghost/core/core/server/models/base/plugins/actions.js - About 1 hr to fix

                                Function filterExpansions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    filterExpansions() {
                                        return [{
                                            key: 'label',
                                            replacement: 'labels.slug'
                                        }, {
                                Severity: Minor
                                Found in ghost/core/core/server/models/member.js - About 1 hr to fix

                                  Function validateRoutes has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  _private.validateRoutes = function validateRoutes(routes) {
                                      if (routes.constructor !== Object) {
                                          throw new errors.ValidationError({
                                              message: tpl(messages.validationError, {
                                                  at: routes,
                                  Severity: Minor
                                  Found in ghost/core/core/server/services/route-settings/validate.js - About 1 hr to fix

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

                                        async function up(connection) {
                                            const oldSetting = await connection('settings')
                                                .where('key', 'members_allow_free_signup')
                                                .select('value', 'created_by', 'updated_by')
                                                .first();

                                      Function beforeImport has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          beforeImport() {
                                              debug('beforeImport');
                                      
                                              let role;
                                              let lookup = {};

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

                                            async function up(knex) {
                                                logging.info('Updating members_status_events for free members');
                                                const freeMemberEvents = await knex('members')
                                                    .select(
                                                        'members.id as member_id',
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language