TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

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

const MainContent: React.FC = () => {
    const {currentUser} = useGlobalData();
    const {route, updateRoute, loadingModal} = useRouting();
    const {isDirty} = useGlobalDirtyState();

Severity: Major
Found in apps/admin-x-settings/src/MainContent.tsx - About 2 hrs to fix

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

    export const getLinkTarget = (action: Action): InternalLink | ExternalLink | undefined => {
        let resourceType = action.resource_type;
    
        if (action.event !== 'deleted') {
            switch (action.resource_type) {
    Severity: Major
    Found in apps/admin-x-framework/src/api/actions.ts - About 2 hrs to fix

      Function fetchAllSubscriptionDeltas has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async fetchAllSubscriptionDeltas() {
              const knex = this.knex;
              const rows = await knex('members_paid_subscription_events')
                  .join('stripe_prices AS price', function () {
                      this.on('price.stripe_price_id', '=', 'members_paid_subscription_events.from_plan')
      Severity: Minor
      Found in ghost/stats-service/lib/SubscriptionStatsService.js - About 2 hrs to fix

        Function comments has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = async function comments(options) {
            // todo: For now check on the comment id to exclude normal pages (we probably have a better way to do this)
        
            const commentId = this.comment_id;
        
        
        Severity: Minor
        Found in ghost/core/core/frontend/helpers/comments.js - About 2 hrs to fix

          Function updateSettings has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              async updateSettings(settings) {
                  // abort if any settings do not match known settings
                  const firstUnknownSetting = settings.find(setting => !this._activeThemeSettings[setting.key]);
          
                  if (firstUnknownSetting) {

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

            module.exports = function (environment) {
                let ENV = {
                    modulePrefix: 'ghost-admin',
                    environment,
                    cdnUrl: process.env.GHOST_CDN_URL || '',
            Severity: Minor
            Found in ghost/admin/config/environment.js - About 1 hr to fix

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

                  permissible: async function permissible(postModel, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
                      let isContributor;
                      let isOwner;
                      let isAdmin;
                      let isEditor;
              Severity: Minor
              Found in ghost/core/core/server/models/post.js - About 1 hr to fix

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

                module.exports = function (Bookshelf) {
                    Bookshelf.Model = Bookshelf.Model.extend({
                        getNullableStringProperties() {
                            const table = schema.tables[this.tableName];
                            return Object.keys(table).filter(column => table[column].nullable);
                Severity: Minor
                Found in ghost/core/core/server/models/base/plugins/data-manipulation.js - About 1 hr to fix

                  Function post has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const post = (attrs, frame) => {
                      const columns = frame && frame.options && frame.options.columns || null;
                      const fields = frame && frame.original && frame.original.query && frame.original.query.fields || null;
                  
                      if (localUtils.isContentAPI(frame)) {

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

                        async function up(knex) {
                            if (DatabaseInfo.isSQLite(knex)) {
                                logging.info('Skipped linking members_created_events and members_subscription_created_events on SQLite');
                                return;
                            }

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

                          async function down(connection) {
                              logging.info('Adding newsletter_show_header setting');
                      
                              const oldSetting = await connection('settings')
                                  .where('key', '=', 'newsletter_show_header')

                        Function getImageSizeFromUrl has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            getImageSizeFromUrl(imagePath) {
                                if (this.storageUtils.isLocalImage(imagePath)) {
                                    // don't make a request for a locally stored image
                                    return this.getImageSizeFromStoragePath(imagePath);
                                }
                        Severity: Minor
                        Found in ghost/core/core/server/lib/image/ImageSize.js - About 1 hr to fix

                          Function SearchBox has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function SearchBox() {
                              const {searchValue, dispatch, inputRef, t} = useContext(AppContext);
                              const containerRef = useRef(null);
                              useEffect(() => {
                                  setTimeout(() => {
                          Severity: Minor
                          Found in apps/sodo-search/src/components/PopupModal.js - About 1 hr to fix

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

                                async permissible(inviteModel, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
                                    const isAdd = (action === 'add');
                            
                                    if (!isAdd) {
                                        if (hasUserPermission && hasApiKeyPermission) {
                            Severity: Minor
                            Found in ghost/core/core/server/models/invite.js - About 1 hr to fix

                              Function update has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      ops.push(function update() {
                                          return ghostBookshelf.Model.edit.call(self, data, options).then(async (user) => {
                                              let roleId;
                              
                                              if (!data.roles || !data.roles.length) {
                              Severity: Minor
                              Found in ghost/core/core/server/models/user.js - About 1 hr to fix

                                Function populateDefaults has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    populateDefaults: async function populateDefaults(unfilteredOptions) {
                                        const options = this.filterOptions(unfilteredOptions, 'populateDefaults');
                                        const self = this;
                                
                                        if (!options.context) {
                                Severity: Minor
                                Found in ghost/core/core/server/models/settings.js - About 1 hr to fix

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

                                      async init() {
                                          const stripeService = require('../stripe');
                                          const createMembersApiInstance = require('./api');
                                          const env = config.get('env');
                                  
                                  
                                  Severity: Minor
                                  Found in ghost/core/core/server/services/members/service.js - About 1 hr to fix

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

                                        async function up(knex) {
                                            logging.info('Adding on delete SET NULL for comments');
                                        
                                            await dropForeign({
                                                fromTable: 'comments',

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

                                          async function down(knex) {
                                              logging.info('Reverting default_content_visibility for specific tiers');
                                      
                                              const settings = await knex('settings')
                                                  .select()

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

                                            async render(lexical, userOptions = {}) {
                                                if (!postsService) {
                                                    const getPostServiceInstance = require('../services/posts/posts-service');
                                                    postsService = getPostServiceInstance();
                                                }
                                        Severity: Minor
                                        Found in ghost/core/core/server/lib/lexical.js - About 1 hr to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language