TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Consider simplifying this complex logical expression.
Open

        if (isNaN(hour) || hour < 0 || hour > 23 || isNaN(minute) || minute < 0 || minute > 59) {
            event.target.value = oldTime;
            return;
        }
Severity: Major
Found in ghost/admin/app/components/editor/publish-options/publish-at.js - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

            if (
                !this.get('lexical') &&
                (
                    this.hasChanged('mobiledoc')
                    || options.force_rerender
    Severity: Major
    Found in ghost/core/core/server/models/post.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

              if (options.newsletter
                  && !this.get('newsletter_id')
                  && this.hasChanged('status')
                  && (newStatus === 'published' || newStatus === 'scheduled' || newStatus === 'sent')) {
                  // Map the passed slug to the id + validate the passed newsletter
      Severity: Major
      Found in ghost/core/core/server/models/post.js - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

                if (
                    !this.get('mobiledoc') &&
                    (
                        this.hasChanged('lexical')
                        || options.force_rerender
        Severity: Major
        Found in ghost/core/core/server/models/post.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                      if (!referrerSource && url.hash && url.hash.includes('#/portal')) {
                          const hashUrl = new URL(window.location.href.replace('/#/portal', ''));
                          refParam = hashUrl.searchParams.get('ref');
                          sourceParam = hashUrl.searchParams.get('source');
                          utmSourceParam = hashUrl.searchParams.get('utm_source');
          Severity: Major
          Found in ghost/core/core/frontend/src/member-attribution/member-attribution.js - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                    if (!options.property && _.includes(context, 'paged')) {
                        description = '';
                    } else {
                        description = data.tag[`${options.property}_description`]
                            || data.tag.meta_description
            Severity: Major
            Found in ghost/core/core/frontend/meta/description.js - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                      if (path && linkRegex.test(path)) {
                          const [,pagePath] = path.match(linkRegex);
                          const {page, pageQuery, pageData} = this.getPageFromLinkPath(pagePath, site) || {};
                          const lastPage = ['accountPlan', 'accountProfile'].includes(page) ? 'accountHome' : null;
                          const showPopup = (
              Severity: Major
              Found in apps/portal/src/App.js - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                        if (!checkVisible(Object.values(generalSearchKeywords).flat()) &&
                            !checkVisible(Object.values(siteSearchKeywords).flat()) &&
                            !checkVisible(Object.values(membershipSearchKeywords).flat()) &&
                            !checkVisible(Object.values(growthSearchKeywords).flat()) &&
                            !checkVisible(Object.values(emailSearchKeywords).flat()) &&
                Severity: Major
                Found in apps/admin-x-settings/src/components/Sidebar.tsx - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                      if (imageURL) {
                          let image = (
                              <div className={imageContainerClassName} style={{
                                  width: (unstyled ? '' : width),
                                  height: (unstyled ? '' : height)
                  Severity: Major
                  Found in apps/admin-x-design-system/src/global/form/ImageUpload.tsx - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                        if (!unstyled) {
                            imageContainerClassName = clsx(
                                'group relative flex justify-center',
                                imageContainerClassName
                            );
                    Severity: Major
                    Found in apps/admin-x-design-system/src/global/form/ImageUpload.tsx - About 40 mins to fix

                      Function isBetween has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      export function isBetween(date, start, end, unit, inclusivity) {
                      Severity: Minor
                      Found in ghost/admin/lib/ember-power-calendar-utils/addon/index.js - About 35 mins to fix

                        Function output has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                output(response, apiUtils, apiConfig, apiImpl, frame) {
                        Severity: Minor
                        Found in ghost/api-framework/lib/pipeline.js - About 35 mins to fix

                          Function attach has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          const attach = function attach(Model, effectedModelId, relation, modelsToAttach, options) {
                          Severity: Minor
                          Found in ghost/core/core/server/models/base/utils.js - About 35 mins to fix

                            Function detach has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            const detach = function detach(Model, effectedModelId, relation, modelsToAttach, options) {
                            Severity: Minor
                            Found in ghost/core/core/server/models/base/utils.js - About 35 mins to fix

                              Function createPublicFileMiddleware has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              function createPublicFileMiddleware(location, file, mime, maxAge, options = {}) {
                              Severity: Minor
                              Found in ghost/core/core/frontend/web/middleware/serve-public-file.js - About 35 mins to fix

                                Function servePublicFile has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                function servePublicFile(location, file, type, maxAge, options = {}) {
                                Severity: Minor
                                Found in ghost/core/core/frontend/web/middleware/serve-public-file.js - About 35 mins to fix

                                  Function getProduct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      getProduct() {
                                          if (this.products.length > 1) {
                                              return luck(10) ? this.products[2]
                                                  : luck(50) ? this.products[1]
                                                      : this.products[0];
                                  Severity: Minor
                                  Found in ghost/data-generator/lib/importers/MembersProductsImporter.js - About 35 mins 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 handleStripe has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  async function handleStripe() {
                                      if (DASH_DASH_ARGS.includes('stripe') || DASH_DASH_ARGS.includes('all')) {
                                          if (DASH_DASH_ARGS.includes('offline') || DASH_DASH_ARGS.includes('browser-tests')) {
                                              return;
                                          }
                                  Severity: Minor
                                  Found in .github/scripts/dev.js - About 35 mins 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 getResourceById has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      async getResourceById(id, type) {
                                          switch (type) {
                                          case 'post':
                                          case 'page': {
                                              const post = await this.models.Post.findOne({id}, {require: false});
                                  Severity: Minor
                                  Found in ghost/member-attribution/lib/UrlTranslator.js - About 35 mins 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 getEventAttribution has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      getEventAttribution(eventModel) {
                                          const _attribution = this.attributionBuilder.build({
                                              id: eventModel.get('attribution_id'),
                                              url: eventModel.get('attribution_url'),
                                              type: eventModel.get('attribution_type'),
                                  Severity: Minor
                                  Found in ghost/member-attribution/lib/MemberAttributionService.js - About 35 mins 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