TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function add has 63 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    add(apiConfig, frame, options = {add: true}) {
        debug('add');

        if (_.get(frame,'options.source')) {
            const html = frame.data.posts[0].html;
Severity: Major
Found in ghost/core/core/server/api/endpoints/utils/serializers/input/posts.js - About 2 hrs to fix

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

    module.exports = (event, model) => {
        const _ = require('lodash');
        const {sequence} = require('@tryghost/promise');
        const api = require('../../api').endpoints;
        const apiFramework = require('@tryghost/api-framework');
    Severity: Major
    Found in ghost/core/core/server/services/webhooks/serialize.js - About 2 hrs to fix

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

          async function up(knex) {
              // This uses the default settings from core/server/data/schema/default-settings/default-settings.json
              const newsletter = {
                  id: (new ObjectId()).toHexString(),
                  uuid: crypto.randomUUID(),

        Function fetchBookmarkData has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async fetchBookmarkData(url, html) {
                const gotOpts = {
                    headers: {
                        'User-Agent': USER_AGENT
                    }
        Severity: Major
        Found in ghost/oembed-service/lib/OEmbedService.js - About 2 hrs to fix

          Function UnsplashModal has 63 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const UnsplashModal = NiceModal.create(() => {
              const {updateRoute} = useRouting();
              const {settings} = useGlobalData();
              const [unsplashEnabled] = getSettingValues<boolean>(settings, ['unsplash']);
              const {mutateAsync: editSettings} = useEditSettings();

            Function Content has 63 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const Content = () => {
                const labs = useLabs();
                const {t} = useAppContext();
            
                const {pagination, member, comments, commentCount, commentsEnabled, title, showCount, secundaryFormCount} = useAppContext();
            Severity: Major
            Found in apps/comments-ui/src/components/content/Content.tsx - About 2 hrs to fix

              `` has 23 functions (exceeds 20 allowed). Consider refactoring.
              Open

              export default Model.extend(Comparable, ValidationEngine, {
                  session: service(),
                  feature: service(),
                  ghostPaths: service(),
                  clock: service(),
              Severity: Minor
              Found in ghost/admin/app/models/post.js - About 2 hrs to fix

                StaffServiceEmails has 23 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class StaffServiceEmails {
                    constructor({logging, models, mailer, settingsHelpers, settingsCache, blogIcon, urlUtils, labs}) {
                        this.logging = logging;
                        this.models = models;
                        this.mailer = mailer;
                Severity: Minor
                Found in ghost/staff-service/lib/StaffServiceEmails.js - About 2 hrs to fix

                  exports has 23 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  module.exports = class EventRepository {
                      constructor({
                          DonationPaymentEvent,
                          EmailRecipient,
                          MemberSubscribeEvent,
                  Severity: Minor
                  Found in ghost/members-api/lib/repositories/EventRepository.js - About 2 hrs to fix

                    `` has 23 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    User = ghostBookshelf.Model.extend({
                    
                        tableName: 'users',
                    
                        actionsCollectCRUD: true,
                    Severity: Minor
                    Found in ghost/core/core/server/models/user.js - About 2 hrs to fix

                      Function buildObjectTypeHandlers has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          buildObjectTypeHandlers(objTypes, actType, context, permissionLoad) {
                              const objectTypeModelMap = {
                                  post: models.Post,
                                  role: models.Role,
                                  user: models.User,
                      Severity: Major
                      Found in ghost/core/core/server/services/permissions/can-this.js - About 2 hrs to fix

                        Function unsubscribeController has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        module.exports = async function unsubscribeController(req, res) {
                            debug('unsubscribeController');
                        
                            const {query} = url.parse(req.url, true);
                        
                        
                        Severity: Major
                        Found in ghost/core/core/frontend/services/routing/controllers/unsubscribe.js - About 2 hrs to fix

                          Function SortingForm has 62 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          export const SortingForm: React.FC = () => {
                              const changeOrder = useOrderChange();
                              const [isOpen, setIsOpen] = useState(false);
                              const [selectedOption, setSelectedOption] = useState('best');
                              const dropdownRef = useRef<HTMLDivElement>(null);
                          Severity: Major
                          Found in apps/comments-ui/src/components/content/forms/SortingForm.tsx - About 2 hrs to fix

                            File Users.tsx has 269 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import React, {useEffect, useState} from 'react';
                            import TopLevelGroup from '../../TopLevelGroup';
                            import clsx from 'clsx';
                            import useQueryParams from '../../../hooks/useQueryParams';
                            import useStaffUsers from '../../../hooks/useStaffUsers';
                            Severity: Minor
                            Found in apps/admin-x-settings/src/components/settings/general/Users.tsx - About 2 hrs to fix

                              File OffersIndex.tsx has 269 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              import {Button, Tab, TabView} from '@tryghost/admin-x-design-system';
                              import {ButtonGroup, ButtonProps, showToast} from '@tryghost/admin-x-design-system';
                              import {Icon} from '@tryghost/admin-x-design-system';
                              import {Modal} from '@tryghost/admin-x-design-system';
                              import {SortMenu} from '@tryghost/admin-x-design-system';

                                Function getPortalPreviewUrl has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    getPortalPreviewUrl(overrides) {
                                        let {
                                            disableBackground = false,
                                            page = 'signup',
                                            button = this.settings.portalButton,
                                Severity: Major
                                Found in ghost/admin/app/services/members-utils.js - About 2 hrs to fix

                                  Function populateStripePricesFromStripePlansSetting has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      async populateStripePricesFromStripePlansSetting(options) {
                                          if (!options) {
                                              return this.models.Product.transaction((transacting) => {
                                                  return this.populateStripePricesFromStripePlansSetting({transacting});
                                              });
                                  Severity: Major
                                  Found in ghost/stripe/lib/StripeMigrations.js - About 2 hrs to fix

                                    Function connectAndSend has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    module.exports.connectAndSend = (socketAddress, message) => {
                                        // Very basic guard against bad calls
                                        if (!socketAddress || !socketAddress.host || !socketAddress.port || !logging || !logging.info || !logging.warn || !message) {
                                            return Promise.resolve();
                                        }
                                    Severity: Major
                                    Found in ghost/bootstrap-socket/lib/bootstrap-socket.js - About 2 hrs to fix

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

                                      module.exports = function (Bookshelf) {
                                          const ParentModel = Bookshelf.Model;
                                      
                                          Bookshelf.Model = Bookshelf.Model.extend({
                                              /**
                                      Severity: Major
                                      Found in ghost/core/core/server/models/base/plugins/overrides.js - About 2 hrs to fix

                                        Function useLimiter has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                        export const useLimiter = () => {
                                            const {config} = useGlobalData();
                                            const [LimitService, setLimitService] = useState<typeof import('@tryghost/limit-service') | null>(null);
                                        
                                            useEffect(() => {
                                        Severity: Major
                                        Found in apps/admin-x-settings/src/hooks/useLimiter.tsx - About 2 hrs to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language