TryGhost/Ghost

View on GitHub

Showing 4,015 of 4,015 total issues

Function articleBodyStyles has 4696 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const articleBodyStyles = (siteUrl: string|undefined) => {
    return `<style>
    /* Table of contents
/* ------------------------------------------------------------

Severity: Major
Found in apps/admin-x-activitypub/src/components/articleBodyStyles.ts - About 3 wks to fix

    File articleBodyStyles.ts has 4699 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const articleBodyStyles = (siteUrl: string|undefined) => {
        return `<style>
        /* Table of contents
    /* ------------------------------------------------------------
    
    
    Severity: Major
    Found in apps/admin-x-activitypub/src/components/articleBodyStyles.ts - About 1 wk to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          describe('getFollowersForProfile', function () {
              test('It returns an array of followers for a profile', async function () {
                  const handle = '@foo@bar.baz';
      
                  const fakeFetch = Fetch({
      Severity: Major
      Found in apps/admin-x-activitypub/src/api/activitypub.test.ts and 1 other location - About 6 days to fix
      apps/admin-x-activitypub/src/api/activitypub.test.ts on lines 1106..1338

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 1082.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          describe('getFollowingForProfile', function () {
              test('It returns a following arrayfor a profile', async function () {
                  const handle = '@foo@bar.baz';
      
                  const fakeFetch = Fetch({
      Severity: Major
      Found in apps/admin-x-activitypub/src/api/activitypub.test.ts and 1 other location - About 6 days to fix
      apps/admin-x-activitypub/src/api/activitypub.test.ts on lines 872..1104

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 1082.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          add(apiConfig, frame, options = {add: true}) {
              debug('add');
      
              if (_.get(frame,'options.source')) {
                  const html = frame.data.pages[0].html;
      ghost/core/core/server/api/endpoints/utils/serializers/input/posts.js on lines 203..283

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 764.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          add(apiConfig, frame, options = {add: true}) {
              debug('add');
      
              if (_.get(frame,'options.source')) {
                  const html = frame.data.posts[0].html;
      ghost/core/core/server/api/endpoints/utils/serializers/input/pages.js on lines 161..241

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 764.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          describe('getInbox', function () {
              test('It passes the token to the inbox endpoint', async function () {
                  const fakeFetch = Fetch({
                      'https://auth.api/': {
                          response: JSONResponse({
      Severity: Major
      Found in apps/admin-x-activitypub/src/api/activitypub.test.ts and 1 other location - About 4 days to fix
      apps/admin-x-activitypub/src/api/activitypub.test.ts on lines 185..330

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 694.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          describe('getOutbox', function () {
              test('It passes the token to the outbox endpoint', async function () {
                  const fakeFetch = Fetch({
                      'https://auth.api/': {
                          response: JSONResponse({
      Severity: Major
      Found in apps/admin-x-activitypub/src/api/activitypub.test.ts and 1 other location - About 4 days to fix
      apps/admin-x-activitypub/src/api/activitypub.test.ts on lines 38..183

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 694.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      File MemberRepository.js has 1327 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      const _ = require('lodash');
      const errors = require('@tryghost/errors');
      const logging = require('@tryghost/logging');
      const tpl = require('@tryghost/tpl');
      const DomainEvents = require('@tryghost/domain-events');
      Severity: Major
      Found in ghost/members-api/lib/repositories/MemberRepository.js - About 3 days to fix

        File activitypub.test.ts has 1227 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import {Activity, ActivityPubAPI} from './activitypub';
        
        function NotFound() {
            return new Response(null, {
                status: 404
        Severity: Major
        Found in apps/admin-x-activitypub/src/api/activitypub.test.ts - About 3 days to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          export default class CollectionRoute extends AuthenticatedRoute {
              @service modals;
              @service router;
              @service session;
          
          
          Severity: Major
          Found in ghost/admin/app/routes/collection.js and 1 other location - About 3 days to fix
          ghost/admin/app/routes/tag.js on lines 7..93

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 526.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          export default class TagRoute extends AuthenticatedRoute {
              @service modals;
              @service router;
              @service session;
          
          
          Severity: Major
          Found in ghost/admin/app/routes/tag.js and 1 other location - About 3 days to fix
          ghost/admin/app/routes/collection.js on lines 7..93

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 526.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          File post.js has 1172 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          // # Post Model
          const _ = require('lodash');
          const crypto = require('crypto');
          const moment = require('moment');
          const {sequence} = require('@tryghost/promise');
          Severity: Major
          Found in ghost/core/core/server/models/post.js - About 3 days to fix

            Function linkSubscription has a Cognitive Complexity of 145 (exceeds 5 allowed). Consider refactoring.
            Open

                async linkSubscription(data, options = {}) {
                    if (!this._stripeAPIService.configured) {
                        throw new errors.BadRequestError({message: tpl(messages.noStripeConnection, {action: 'link Stripe Subscription'})});
                    }
            
            
            Severity: Minor
            Found in ghost/members-api/lib/repositories/MemberRepository.js - About 2 days 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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            module.exports = createTransactionalMigration(
                async function up(knex) {
                    logging.info('Adding Admin API key for "Self-Serve Migration Integration"');
            
                    const integration = await knex('integrations').where({
            ghost/core/core/server/data/migrations/versions/5.3/2022-07-06-09-26-add-ghost-explore-integration-api-key.js on lines 7..76

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 491.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            module.exports = createTransactionalMigration(
                async function up(knex) {
                    logging.info('Adding Admin API key for Ghost Explore Integration');
            
                    const integration = await knex('integrations').where({
            ghost/core/core/server/data/migrations/versions/5.40/2023-03-21-19-02-add-self-serve-integration-api-key.js on lines 7..76

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 491.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                describe('getFollowers', function () {
                    test('It passes the token to the followers endpoint', async function () {
                        const fakeFetch = Fetch({
                            'https://auth.api/': {
                                response: JSONResponse({
            Severity: Major
            Found in apps/admin-x-activitypub/src/api/activitypub.test.ts and 1 other location - About 2 days to fix
            apps/admin-x-activitypub/src/api/activitypub.test.ts on lines 565..661

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 488.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                describe('getFollowersExpanded', function () {
                    test('It passes the token to the followers endpoint', async function () {
                        const fakeFetch = Fetch({
                            'https://auth.api/': {
                                response: JSONResponse({
            Severity: Major
            Found in apps/admin-x-activitypub/src/api/activitypub.test.ts and 1 other location - About 2 days to fix
            apps/admin-x-activitypub/src/api/activitypub.test.ts on lines 467..563

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 488.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            File Frame.styles.js has 1088 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /** By default, CRAs webpack bundle combines and appends the main css at root level, so they are not applied inside iframe
             * This uses a hack where we append `<style> </style>` tag with all CSS inside the head of iframe dynamically, thus making it available easily
             * We can create separate variables to keep styles grouped logically, and export them as one appended string
            */
            
            
            Severity: Major
            Found in apps/portal/src/components/Frame.styles.js - About 2 days to fix

              File schema.js has 1065 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /* String Column Sizes Information
               * (From: https://github.com/TryGhost/Ghost/pull/7932)
               *
               * Small strings = length 50
               * Medium strings = length 191
              Severity: Major
              Found in ghost/core/core/server/data/schema/schema.js - About 2 days to fix
                Severity
                Category
                Status
                Source
                Language