TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

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

module.exports = function (Bookshelf) {
    Bookshelf.Model = Bookshelf.Model.extend({}, {
        /**
         * ### Generate Slug
         * Create a string to act as the permalink for an object.
Severity: Major
Found in ghost/core/core/server/models/base/plugins/generate-slug.js - About 2 hrs to fix

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

        setFromZip: async (zip) => {
            const themeName = getStorage().getSanitizedFileName(zip.name.split('.zip')[0]);
            const backupName = `${themeName}_${ObjectID()}`;
    
            // check if zip name matches one of the default themes
    Severity: Major
    Found in ghost/core/core/server/services/themes/storage.js - About 2 hrs to fix

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

                  getText(url, type, email) {
                      const siteTitle = settingsCache.get('title');
                      switch (type) {
                      case 'subscribe':
                          return trimLeadingWhitespace`
      Severity: Major
      Found in ghost/core/core/server/services/members/api.js - About 2 hrs to fix

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

        function getLinkTarget(ev) {
            let resourceType = ev.resource_type;
        
            if (ev.event !== 'deleted') {
                switch (ev.resource_type) {
        Severity: Major
        Found in ghost/admin/app/helpers/parse-history-event.js - About 2 hrs to fix

          Function _uploadSuccess has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _uploadSuccess(importResponse) {
                  let importedCount = importResponse.meta.stats.imported;
                  const erroredMembers = importResponse.meta.stats.invalid;
                  let errorCount = erroredMembers.length;
                  const errorList = {};
          Severity: Major
          Found in ghost/admin/app/components/modal-import-members.js - About 2 hrs to fix

            Function mockNewsletters has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function mockNewsletters(server) {
                server.get('/newsletters/', paginatedResponse('newsletters'));
                server.get('/newsletters/:id/');
            
                server.post('/newsletters/', function ({newsletters}, {queryParams}) {
            Severity: Major
            Found in ghost/admin/mirage/config/newsletters.js - About 2 hrs to fix

              Function updatePortalPlansSetting has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                Function ImplWrapper has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        obj[method] = async function ImplWrapper() {
                            const apiConfig = {docName, method};
                            let options;
                            let data;
                            let frame;
                Severity: Major
                Found in ghost/api-framework/lib/pipeline.js - About 2 hrs to fix

                  Function validateTaxonomies has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  _private.validateTaxonomies = function validateTaxonomies(taxonomies) {
                      if (taxonomies.constructor !== Object) {
                          throw new errors.ValidationError({
                              message: tpl(messages.validationError, {
                                  at: taxonomies,
                  Severity: Major
                  Found in ghost/core/core/server/services/route-settings/validate.js - About 2 hrs to fix

                    Function prepAttrsForEmailVerification has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        async prepAttrsForEmailVerification(attrs, newsletter) {
                            const cleanedAttrs = _.cloneDeep(attrs);
                            const emailsToVerify = [];
                            const emailProperties = [
                                {property: 'sender_email', type: 'from', emptyable: true, error: messages.senderEmailNotAllowed}
                    Severity: Major
                    Found in ghost/core/core/server/services/newsletters/NewslettersService.js - About 2 hrs to fix

                      Function formatUrl has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export const formatUrl = (value: string, baseUrl?: string, nullable?: boolean) => {
                          if (nullable && !value) {
                              return {save: null, display: ''};
                          }
                      
                      
                      Severity: Major
                      Found in apps/admin-x-design-system/src/utils/formatUrl.ts - About 2 hrs to fix

                        Function formatPostTime has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export function formatPostTime(timeago, {timezone = 'etc/UTC', format, relative, absolute, scheduled, short}) {
                            if (relative) {
                                // No special handling, just use moment.from
                                return moment(timeago).from(moment.utc());
                            }
                        Severity: Minor
                        Found in ghost/admin/app/helpers/gh-format-post-time.js - About 2 hrs to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function model has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                            model(params) {
                                const user = this.session.user;
                                let filterParams = {tag: params.tag, visibility: params.visibility};
                                let paginationParams = {
                                    perPageParam: 'limit',
                        Severity: Minor
                        Found in ghost/admin/app/routes/posts.js - About 2 hrs to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function updateSubscription has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                            async updateSubscription(data, options) {
                                const sharedOptions = {
                                    transacting: options ? options.transacting : null
                                };
                                if (!this._stripeAPIService.configured) {
                        Severity: Minor
                        Found in ghost/members-api/lib/repositories/MemberRepository.js - About 2 hrs to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function prepareUserMessage has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                        const prepareUserMessage = function prepareUserMessage(err, req) {
                            const userError = {
                                message: err.message,
                                context: err.context
                            };
                        Severity: Minor
                        Found in ghost/mw-error-handler/lib/mw-error-handler.js - About 2 hrs to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function exports has a Cognitive Complexity of 17 (exceeds 5 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 2 hrs to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function prepSettingsForEmailVerification has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                            async prepSettingsForEmailVerification(settings, getSetting) {
                                const filteredSettings = [];
                                const emailsToVerify = [];
                        
                                for (const setting of settings) {
                        Severity: Minor
                        Found in ghost/core/core/server/services/settings/SettingsBREADService.js - About 2 hrs to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function exports has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                        module.exports = createIrreversibleMigration(async (knex) => {
                            logging.info(`Starting regeneration of posts HTML`);
                        
                            await knex.transaction(async (trx) => {
                                // get list of posts ids, use .forUpdate to lock rows until the transaction is finished

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function exports has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                        module.exports = createIrreversibleMigration(async (knex) => {
                            logging.info('Starting re-generation of posts html.');
                        
                            await knex.transaction(async (trx) => {
                                // get list of posts ids, use .forUpdate to lock rows until the transaction is finished

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function doImport has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                            doImport: async function doImport(importData, importOptions) {
                                debug('doImport');
                                importOptions = importOptions || {};
                        
                                if (importOptions.importTag && importData?.data?.posts) {
                        Severity: Minor
                        Found in ghost/core/core/server/data/importer/importers/data/data-importer.js - About 2 hrs to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Severity
                        Category
                        Status
                        Source
                        Language