TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

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

    edit: function edit(data, unfilteredOptions) {
        let options = this.filterOptions(unfilteredOptions, 'edit', {extraAllowedProperties: ['id']});

        const editPost = () => {
            options.forUpdate = true;
Severity: Minor
Found in ghost/core/core/server/models/post.js - About 1 hr to fix

    Function testImportThreshold has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async testImportThreshold() {
            if (!isFinite(this._importTriggerThreshold)) {
                // Infinite threshold, quick path
                return;
            }
    Severity: Minor
    Found in ghost/verification-trigger/lib/VerificationTrigger.js - About 1 hr to fix

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

              query() {
                  /**
                   * @NOTE:
                   * We fetch all posts with `columns:id` to increase the speed of this endpoint.
                   * And if you trigger `post.destroy(..)`, this will trigger bookshelf and model events.
      Severity: Minor
      Found in ghost/core/core/server/api/endpoints/db.js - About 1 hr to fix

        Function countRelations has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            countRelations() {
                return {
                    posts(modelOrCollection) {
                        modelOrCollection.query('columns', 'newsletters.*', (qb) => {
                            qb.count('posts.id')
        Severity: Minor
        Found in ghost/core/core/server/models/newsletter.js - About 1 hr to fix

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

          module.exports = function (Bookshelf) {
              Bookshelf.Model = Bookshelf.Model.extend({
                  /**
                   * Return a relation, and load it if it hasn't been loaded already (or force a refresh with the forceRefresh option).
                   * refs https://github.com/TryGhost/Team/issues/1626
          Severity: Minor
          Found in ghost/core/core/server/models/base/plugins/relations.js - About 1 hr to fix

            Function clickEventMapper has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const clickEventMapper = (json, frame) => {
                const linkFields = [
                    'from',
                    'to'
                ];

              Function serve has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  serve(options) {
                      const self = this;
              
                      return function downloadTheme(req, res, next) {
                          const themeName = options.name;
              Severity: Minor
              Found in ghost/core/core/server/services/themes/ThemeStorage.js - About 1 hr to fix

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

                    constructor({identifier, filter, resourceType, permalink, queue, resources, urls, position}) {
                        this.identifier = identifier;
                        this.resourceType = resourceType;
                        this.permalink = permalink;
                        this.queue = queue;
                Severity: Minor
                Found in ghost/core/core/server/services/url/UrlGenerator.js - About 1 hr to fix

                  Function startFetch has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      async startFetch() {
                          if (this.fetching) {
                              logging.info('Email analytics fetch already running, skipping');
                              return;
                          }

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

                        async function up(knex) {
                            logging.info('Restoring member<>tier mapping for members with paid status');
                            try {
                                // fetch all members with a paid status that don't have a members_products record
                                // and have a members_product_events record with an action of "added"

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

                          async function up(knex) {
                              const subscriptionsToUpdate = await knex('members_stripe_customers_subscriptions AS s')
                                  .join('offers AS o', 's.offer_id', '=', 'o.id')
                                  .where('o.duration', '=', 'forever')
                                  .andWhere('s.mrr', '!=', 0)

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

                        module.exports = createIrreversibleMigration(async function up(connection) {
                            if (DatabaseInfo.isMySQL(connection)) {
                                logging.info('Skipping removal of orphaned stripe records for MySQL');
                                return;
                            }

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

                              async function down(connection) {
                                  const accessSetting = await connection('settings')
                                      .where('key', 'members_signup_access')
                                      .select('value')
                                      .first();

                            Function doExport has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const doExport = async function doExport(options) {
                                options = options || {include: []};
                            
                                try {
                                    const tables = await commands.getTables(options.transacting);
                            Severity: Minor
                            Found in ghost/core/core/server/data/exporter/exporter.js - About 1 hr to fix

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

                                  async function up(knex) {
                                      logging.info('Adding existing subscribers to default newsletter');
                              
                                      const newsletter = await knex('newsletters')
                                          .orderBy('sort_order', 'asc')

                                Function privateBlog has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                const privateBlog = () => {
                                    const ExpressBrute = require('express-brute');
                                    const BruteKnex = require('brute-knex');
                                    const db = require('../../../../data/db');
                                
                                
                                Severity: Minor
                                Found in ghost/core/core/server/web/shared/middleware/api/spam-prevention.js - About 1 hr to fix

                                  Function getState has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      async getState() {
                                          let state = states.READY;
                                          try {
                                              await this.knexMigrator.isDatabaseOK();
                                              return state;
                                  Severity: Minor
                                  Found in ghost/core/core/server/data/db/DatabaseStateManager.js - About 1 hr to fix

                                    Function handler has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    module.exports = function handler(siteApp) {
                                        const verifyResourceType = function verifyResourceType(req, res, next) {
                                            const resourceWithoutPage = req.params.resource.replace(/-\d+$/, '');
                                            if (!Object.prototype.hasOwnProperty.call(manager, resourceWithoutPage)) {
                                                return res.sendStatus(404);
                                    Severity: Minor
                                    Found in ghost/core/core/frontend/services/sitemap/handler.js - About 1 hr to fix

                                      Function StylesWrapper has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                      const StylesWrapper = () => {
                                          return {
                                              modalContainer: {
                                                  zIndex: '3999999',
                                                  position: 'fixed',
                                      Severity: Minor
                                      Found in apps/sodo-search/src/components/PopupModal.js - About 1 hr to fix

                                        Function render has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            render() {
                                                const hasText = this.hasText();
                                                const {member} = this.context;
                                                const triggerBtnClass = member ? 'halo' : '';
                                        
                                        
                                        Severity: Minor
                                        Found in apps/portal/src/components/TriggerButton.js - About 1 hr to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language