TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function sendAuthCodeToUser has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async function sendAuthCodeToUser(req, res) {
        const session = await getSession(req, res);
        const token = await generateAuthCodeForUser(req, res);
        const user = await findUserById({id: session.user_id});

Severity: Minor
Found in ghost/session-service/lib/session-service.js - About 1 hr to fix

    Function compute has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        compute(
            positionalParams,
            {excludedEvents = [], includeEvents = null, member = '', post = '', excludeEmailEvents = false}
        ) {
            const excludedEventsSet = new Set();
    Severity: Minor
    Found in ghost/admin/app/helpers/members-event-filter.js - About 1 hr to fix

      Function finalise has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async finalise() {
              const stripeProducts = await this.transaction.select('id', 'product_id', 'stripe_product_id').from('stripe_products');
              const stripePrices = await this.transaction.select('id', 'stripe_product_id', 'interval').from('stripe_prices');
      
              const products = await this.transaction.select('id').from('products');
      Severity: Minor
      Found in ghost/data-generator/lib/importers/ProductsImporter.js - About 1 hr to fix

        Function create has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static create(type, months) {
                if (!type || typeof type !== 'string') {
                    throw new InvalidOfferDuration({
                        message: 'Offer `duration` must be a string.'
                    });
        Severity: Minor
        Found in ghost/offers/lib/domain/models/OfferDuration.js - About 1 hr to fix

          Function showAlert has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              showAlert(message, options = {}) {
                  options = options || {};
          
                  if (!options.isApiError && (!options.type || options.type === 'error')) {
                      if (this.config.sentry_dsn) {
          Severity: Minor
          Found in ghost/admin/app/services/notifications.js - About 1 hr to fix

            Function willTransition has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @action
                willTransition(transition) {
                    let isExploreTransition = false;
            
                    if (transition) {
            Severity: Minor
            Found in ghost/admin/app/routes/explore/index.js - About 1 hr to fix

              Function server has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const server = require('http').createServer(async (req, res) => {
                  if (!req.method) {
                      res.writeHead(405);
                      return res.end('Method not allowed.');
                  }
              Severity: Minor
              Found in ghost/members-ssr/example.js - About 1 hr to fix

                Function _setAttributionMetadata has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    async _setAttributionMetadata(metadata) {
                        // Don't allow to set the source manually
                        delete metadata.attribution_id;
                        delete metadata.attribution_url;
                        delete metadata.attribution_type;
                Severity: Minor
                Found in ghost/members-api/lib/controllers/RouterController.js - About 1 hr to fix

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

                      filterExpansions: function filterExpansions() {
                          const postsMetaKeys = _.without(ghostBookshelf.model('PostsMeta').prototype.orderAttributes(), 'posts_meta.id', 'posts_meta.post_id');
                  
                          const expansions = [{
                              key: 'primary_tag',
                  Severity: Minor
                  Found in ghost/core/core/server/models/post.js - About 1 hr to fix

                    Function getReferrersHistory has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        async getReferrersHistory() {
                            const paidConversionEntries = await this.fetchAllPaidConversionSources();
                            const signupEntries = await this.fetchAllSignupSources();
                    
                            const allEntries = signupEntries.map((entry) => {
                    Severity: Minor
                    Found in ghost/stats-service/lib/ReferrersStatsService.js - About 1 hr to fix

                      Function getProductForDonations has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          async getProductForDonations({name}) {
                              const existingDonationPrices = await this.StripePriceModel
                                  .where({
                                      type: 'donation'
                                  })
                      Severity: Minor
                      Found in ghost/payments/lib/PaymentsService.js - About 1 hr to fix

                        Function parseDefaultSettings has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function parseDefaultSettings() {
                            const defaultSettingsInCategories = require('../data/schema/').defaultSettings;
                            const defaultSettingsFlattened = {};
                        
                            const dynamicDefault = {
                        Severity: Minor
                        Found in ghost/core/core/server/models/settings.js - About 1 hr to fix

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

                              edit(apiConfig, frame) {
                                  // CASE: allow shorthand syntax where a single key and value are passed to edit instead of object and options
                                  if (_.isString(frame.data)) {
                                      frame.data = {settings: [{key: frame.data, value: frame.options}]};
                                  }

                            Function commentMapper has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const commentMapper = (model, frame) => {
                                const jsonModel = model.toJSON ? model.toJSON(frame.options) : model;
                            
                                const response = _.pick(jsonModel, commentFields);
                            
                            

                              Function user has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  user: function (id) {
                                      return models.User.findOne({id: id}, {withRelated: ['permissions', 'roles', 'roles.permissions']})
                                          .then(function (foundUser) {
                                          // CASE: {context: {user: id}} where the id is not in our database
                                              if (!foundUser) {
                              Severity: Minor
                              Found in ghost/core/core/server/services/permissions/providers.js - About 1 hr to fix

                                Function onCreating has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        onCreating: function onCreating(model, attr, options) {
                                            if (Object.prototype.hasOwnProperty.call(schema.tables[this.tableName], 'created_by')) {
                                                if (!options.importing || (options.importing && !this.get('created_by'))) {
                                                    this.set('created_by', String(this.contextUser(options)));
                                                }
                                Severity: Minor
                                Found in ghost/core/core/server/models/base/plugins/events.js - About 1 hr to fix

                                  Function permissible has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      async permissible(commentModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission, hasMemberPermission) {
                                          const self = this;
                                  
                                          if (hasUserPermission) {
                                              return true;
                                  Severity: Minor
                                  Found in ghost/core/core/server/models/comment.js - About 1 hr to fix

                                    Function promises has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                            const promises = data.map(function (item) {
                                                if (item.toJSON) {
                                                    item = item.toJSON();
                                                }
                                                if (!(_.isString(item.key) && item.key.length > 0)) {
                                    Severity: Minor
                                    Found in ghost/core/core/server/models/settings.js - About 1 hr to fix

                                      Function query has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                              async query(frame) {
                                                  const paidMembers = await membersService.api.memberBREADService.browse({limit: 0, filter: 'status:paid'});
                                                  if (_.get(paidMembers, 'meta.pagination.total') !== 0) {
                                                      throw new BadRequestError({
                                                          message: 'Cannot disconnect Stripe whilst you have active subscriptions.'
                                      Severity: Minor
                                      Found in ghost/core/core/server/api/endpoints/settings.js - About 1 hr to fix

                                        Function init has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            async init() {
                                                if (this.service) {
                                                    // Already done
                                                    return;
                                                }
                                        Severity: Minor
                                        Found in ghost/core/core/server/services/link-tracking/index.js - About 1 hr to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language