TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function validatePassword has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function validatePassword(password, email, blogTitle) {
    const validationResult = {isValid: true};
    const disallowedPasswords = ['password', 'ghost', 'passw0rd'];
    let blogUrl = urlUtils.urlFor('home', true);

Severity: Minor
Found in ghost/core/core/server/lib/validate-password.js - About 1 hr to fix

    Function price has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function price(planOrAmount, options) {
        let plan;
        let amount;
        if (arguments.length === 1) {
            options = planOrAmount;
    Severity: Minor
    Found in ghost/core/core/frontend/helpers/price.js - About 1 hr to fix

      Function servePublicFileMiddleware has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          return function servePublicFileMiddleware(req, res, next) {
              if (cache && matchCacheKey(req, cache)) {
                  res.writeHead(200, cache.headers);
                  return res.end(cache.body);
              }
      Severity: Minor
      Found in ghost/core/core/frontend/web/middleware/serve-public-file.js - About 1 hr to fix

        Function handleEvent has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async handleEvent(type, event) {
                if (type === MilestoneCreatedEvent && event.data.milestone) {
                    await this.emails.notifyMilestoneReceived(event.data);
                }
        
        
        Severity: Minor
        Found in ghost/staff-service/lib/StaffService.js - About 1 hr to fix

          Function createCustomNotification has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              async createCustomNotification(notification) {
                  if (!notification || !notification.messages || notification.messages.length === 0) {
                      debug(`Skipping notification creation as there are no messages to process`);
                      return;
                  }
          Severity: Minor
          Found in ghost/update-check-service/lib/UpdateCheckService.js - About 1 hr to fix

            Function setupAdminApp has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function setupAdminApp() {
                debug('Admin setup start');
                const adminApp = express('admin');
            
                // Admin assets
            Severity: Minor
            Found in ghost/core/core/server/web/admin/app.js - About 1 hr to fix

              Function constructor has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  constructor({NewsletterModel, MemberModel, mail, singleUseTokenProvider, urlUtils, limitService, labs, emailAddressService}) {
                      this.NewsletterModel = NewsletterModel;
                      this.MemberModel = MemberModel;
                      this.urlUtils = urlUtils;
                      /** @private */
              Severity: Minor
              Found in ghost/core/core/server/services/newsletters/NewslettersService.js - About 1 hr to fix

                Function down has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    async function down(knex) {
                        logging.info('Restoring foreign key for comments');
                    
                        await dropForeign({
                            fromTable: 'comments',

                  Function up has 45 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 fetchOembedData has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        async fetchOembedData(url, html, cardType) {
                            // Lazy require the library to keep boot quick
                            const cheerio = require('cheerio');
                    
                            // check for <link rel="alternate" type="application/json+oembed"> element
                    Severity: Minor
                    Found in ghost/oembed-service/lib/OEmbedService.js - About 1 hr to fix

                      Function fontClassName has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          const fontClassName = (fontName: string, heading: boolean = true) => {
                              let className = '';
                              if (fontName === 'Cardo') {
                                  className = clsx('font-cardo', heading && 'font-bold');
                              } else if (fontName === 'Manrope') {

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

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

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

                          const validate = (config, attrs) => {
                              let errors = [];
                          
                              _.each(config, (value, key) => {
                                  if (value.required && !attrs[key]) {
                          Severity: Minor
                          Found in ghost/api-framework/lib/validators/input/all.js - About 1 hr to fix

                            Function prepareError has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            module.exports.prepareError = function prepareError(err, req, res, next) {
                                debug(err);
                            
                                if (Array.isArray(err)) {
                                    err = err[0];
                            Severity: Minor
                            Found in ghost/mw-error-handler/lib/mw-error-handler.js - About 1 hr to fix

                              Function notifyDonationReceived has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  async notifyDonationReceived({donationPaymentEvent}) {
                                      const emailPromises = [];
                                      const users = await this.models.User.getEmailAlertUsers('donation');
                                      const formattedAmount = this.getFormattedAmount({currency: donationPaymentEvent.currency, amount: donationPaymentEvent.amount / 100});
                              
                              
                              Severity: Minor
                              Found in ghost/staff-service/lib/StaffServiceEmails.js - About 1 hr to fix

                                Function unparse has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const unparse = (rows, columns = DEFAULT_COLUMNS.slice()) => {
                                    columns = columns.map((column) => {
                                        if (column === 'subscribed') {
                                            return 'subscribed_to_emails';
                                        }
                                Severity: Minor
                                Found in ghost/members-csv/lib/unparse.js - About 1 hr to fix

                                  Function _pingUrl has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  SchedulingDefault.prototype._pingUrl = function (object) {
                                      const {url, time} = object;
                                  
                                      debug('Ping url', url, moment().format('YYYY-MM-DD HH:mm:ss'), moment(time).format('YYYY-MM-DD HH:mm:ss'));
                                  
                                  
                                  Severity: Minor
                                  Found in ghost/core/core/server/adapters/scheduling/scheduling-default.js - About 1 hr to fix

                                    Function getSignupEvents has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        async getSignupEvents(options = {}, filter) {
                                            options = {
                                                ...options,
                                                withRelated: [
                                                    'member',
                                    Severity: Minor
                                    Found in ghost/members-api/lib/repositories/EventRepository.js - About 1 hr to fix

                                      Function getHistory has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          async getHistory() {
                                              // Fetch current total amounts and start counting from there
                                              const totals = await this.getCurrentMrr();
                                      
                                              const rows = await this.fetchAllDeltas();
                                      Severity: Minor
                                      Found in ghost/stats-service/lib/MrrStatsService.js - About 1 hr to fix

                                        Function serialize has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            serialize(options) {
                                                const defaultSerializedObject = ghostBookshelf.Model.prototype.serialize.call(this, options);
                                        
                                                const serialized = {
                                                    id: defaultSerializedObject.subscription_id,
                                        Severity: Minor
                                        Found in ghost/core/core/server/models/stripe-customer-subscription.js - About 1 hr to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language