TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

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

module.exports = (path, headerMapping, defaultLabels = []) => {
    return new Promise(function (resolve, reject) {
        const csvFileStream = fs.createReadStream(path);
        const csvParserStream = papaparse.parse(papaparse.NODE_STREAM_INPUT, {
            header: true,
Severity: Major
Found in ghost/members-csv/lib/parse.js - About 2 hrs to fix

    Function reassignByAuthor has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            reassignByAuthor: async function reassignByAuthor(unfilteredOptions) {
                let options = this.filterOptions(unfilteredOptions, 'reassignByAuthor', {extraAllowedProperties: ['id']});
                let authorId = options.id;
    
                if (!authorId) {
    Severity: Major
    Found in ghost/core/core/server/models/relations/authors.js - About 2 hrs to fix

      Function optimiseFilterCacheability has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function optimiseFilterCacheability(resource, options) {
          const noOptimisation = {
              options,
              parseResult(result) {
                  return result;
      Severity: Major
      Found in ghost/core/core/frontend/helpers/get.js - About 2 hrs to fix

        File timezones.js has 266 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        export default [
            {
                name: 'Pacific/Pago_Pago',
                label: '(GMT -11:00) Midway Island, Samoa'
            },
        Severity: Minor
        Found in ghost/admin/mirage/fixtures/timezones.js - About 2 hrs to fix

          Function default has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function () {
              this.namespace = ghostPaths().apiRoot;
              // this.timing = 400;      // delay for each request, automatically set to 0 during testing
              this.logging = false;
          
          
          Severity: Major
          Found in ghost/admin/mirage/routes-test.js - About 2 hrs to fix

            Function populateProductsAndPrices has 59 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

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

              Function createCheckoutSetupSession has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async createCheckoutSetupSession(req, res) {
                      const identity = req.body.identity;
              
                      if (!identity) {
                          res.writeHead(400);
              Severity: Major
              Found in ghost/members-api/lib/controllers/RouterController.js - About 2 hrs to fix

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

                    async add(data, options) {
                        if (!this.stripeService.configured && (data.comped || data.stripe_customer_id)) {
                            const property = data.comped ? 'comped' : 'stripe_customer_id';
                            throw new errors.ValidationError({
                                message: tpl(messages.stripeNotConnected),
                Severity: Major
                Found in ghost/members-api/lib/services/MemberBREADService.js - About 2 hrs to fix

                  File users.js has 265 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  const tpl = require('@tryghost/tpl');
                  const errors = require('@tryghost/errors');
                  const models = require('../../models');
                  const permissionsService = require('../../services/permissions');
                  const dbBackup = require('../../data/db/backup');
                  Severity: Minor
                  Found in ghost/core/core/server/api/endpoints/users.js - About 2 hrs to fix

                    File CommentsService.js has 265 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    const tpl = require('@tryghost/tpl');
                    const errors = require('@tryghost/errors');
                    const {MemberCommentEvent} = require('@tryghost/member-events');
                    const DomainEvents = require('@tryghost/domain-events');
                    
                    
                    Severity: Minor
                    Found in ghost/core/core/server/services/comments/CommentsService.js - About 2 hrs to fix

                      Function beforeImport has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          beforeImport() {
                              debug('beforeImport');
                      
                              this.sanitizeAttributes();
                              this.addNestedRelations();
                      Severity: Major
                      Found in ghost/core/core/server/data/importer/importers/data/PostsImporter.js - About 2 hrs to fix

                        Function checkoutPlan has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                async checkoutPlan({plan, tierId, cadence, cancelUrl, successUrl, email: customerEmail, name, offerId, newsletters, metadata = {}} = {}) {
                                    const siteUrlObj = new URL(siteUrl);
                                    const identity = await api.member.identity();
                                    const url = endpointFor({type: 'members', resource: 'create-stripe-checkout-session'});
                        
                        
                        Severity: Major
                        Found in apps/portal/src/utils/api.js - About 2 hrs to fix

                          Function itemsToHtml has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const itemsToHtml = (items) => {
                              let itemHTMLChunks = [];
                              items.forEach((item) => {
                                  let type = item.item_type;
                          
                          
                          Severity: Major
                          Found in ghost/importer-revue/lib/json-to-html.js - About 2 hrs to fix

                            Function subscribeToEvents has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                subscribeToEvents() {
                                    // @NOTE: event handling should be moved to the client - Ghost app
                                    //        Leaving commented out handlers here to move them all together
                            
                                    // this.DomainEvents.subscribe(PostDeletedEvent, async (event: PostDeletedEvent) => {
                            Severity: Major
                            Found in ghost/collections/src/CollectionsService.ts - About 2 hrs to fix

                              Function PortalLinks has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              const PortalLinks: React.FC = () => {
                                  const [isDataAttributes, setIsDataAttributes] = useState(false);
                                  const [selectedTier, setSelectedTier] = useState('');
                                  const {siteData} = useGlobalData();
                                  const {data: {tiers: allTiers} = {}} = useBrowseTiers();

                                CollectionsService has 22 functions (exceeds 20 allowed). Consider refactoring.
                                Open

                                export class CollectionsService {
                                    private collectionsRepository: CollectionRepository;
                                    private postsRepository: PostsRepository;
                                    private DomainEvents: {
                                        // eslint-disable-next-line @typescript-eslint/no-explicit-any
                                Severity: Minor
                                Found in ghost/collections/src/CollectionsService.ts - About 2 hrs to fix

                                  Function getIcon has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      getIcon(event) {
                                          let icon;
                                  
                                          if (event.type === 'login_event') {
                                              icon = 'logged-in';
                                  Severity: Major
                                  Found in ghost/admin/app/helpers/parse-member-event.js - About 2 hrs to fix

                                    Function mockAuthentication has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    export default function mockAuthentication(server) {
                                        // Password sign-in
                                        server.post('/session', function () {
                                            return new Response(201);
                                        });
                                    Severity: Major
                                    Found in ghost/admin/mirage/config/authentication.js - About 2 hrs to fix

                                      Function attachSubscriptionsToMember has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          attachSubscriptionsToMember(member) {
                                              if (!member.products || !Array.isArray(member.products)) {
                                                  return member;
                                              }
                                      
                                      
                                      Severity: Major
                                      Found in ghost/members-api/lib/services/MemberBREADService.js - About 2 hrs to fix

                                        Function findPage has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                                findPage: async function findPage(unfilteredOptions) {
                                                    const options = this.filterOptions(unfilteredOptions, 'findPage');
                                                    const itemCollection = this.getFilteredCollection(options);
                                                    const requestedColumns = options.columns;
                                                    // make sure we include plaintext and custom_excerpt if excerpt is requested
                                        Severity: Major
                                        Found in ghost/core/core/server/models/base/plugins/crud.js - About 2 hrs to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language