TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function reassignPost has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            const reassignPost = (async () => {
                let trx = options.transacting;
                let knex = ghostBookshelf.knex;

                try {
Severity: Minor
Found in ghost/core/core/server/models/relations/authors.js - About 1 hr to fix

    Function query has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            query(frame) {
                return Promise.resolve()
                    .then(() => {
                        return auth.setup.assertSetupCompleted(false)();
                    })
    Severity: Minor
    Found in ghost/core/core/server/api/endpoints/authentication.js - About 1 hr to fix

      Function replyToComment has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async replyToComment(parent, member, comment, options) {
              this.checkEnabled();
              const memberModel = await this.models.Member.findOne({
                  id: member
              }, {
      Severity: Minor
      Found in ghost/core/core/server/services/comments/CommentsService.js - About 1 hr to fix

        Function parseRedirectsFile has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const parseRedirectsFile = (content, ext) => {
            if (ext === '.json') {
                let redirects;
        
                try {

          Function notImplemented has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const notImplemented = function notImplemented(req, res, next) {
              // CASE: user is logged in, allow
              if (!req.api_key) {
                  return next();
              }
          Severity: Minor
          Found in ghost/core/core/server/web/api/endpoints/admin/middleware.js - About 1 hr to fix

            Function getImageSizeFromStoragePath has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                getImageSizeFromStoragePath(imagePath) {
                    let filePath;
            
                    imagePath = this.urlUtils.urlFor('image', {image: imagePath}, true);
            
            
            Severity: Minor
            Found in ghost/core/core/server/lib/image/ImageSize.js - About 1 hr to fix

              Function exports has 44 lines of code (exceeds 25 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

                Function handle has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    async handle(argv = {}) {
                        // If we can't stream, throw an error while creating the connection
                        process.env.REQUIRE_INFILE_STREAM = '1';
                        const knex = require('../server/data/db/connection');
                
                
                Severity: Minor
                Found in ghost/core/core/cli/generate-data.js - About 1 hr to fix

                  Function intercept has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      intercept<T>(context: ExecutionContext, next: CallHandler): Observable<T> {
                          if (context.getType() !== 'http') {
                              return next.handle();
                          }
                          const [
                  Severity: Minor
                  Found in ghost/ghost/src/nestjs/interceptors/location-header.interceptor.ts - About 1 hr to fix

                    Function renderOfferMessage has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        renderOfferMessage({offer, product, t}) {
                            const offerMessages = {
                                forever: t(`{{amount}} off forever.`, {
                                    amount: this.getOffAmount({offer})
                                }),
                    Severity: Minor
                    Found in apps/portal/src/components/pages/OfferPage.js - About 1 hr to fix

                      Function getInputFields has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          getInputFields({state, fieldNames}) {
                              const {site: {portal_name: portalName}, t} = this.context;
                      
                              const errors = state.errors || {};
                              const fields = [
                      Severity: Minor
                      Found in apps/portal/src/components/pages/SignupPage.js - About 1 hr to fix

                        Function UniversalImportModal has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const UniversalImportModal: React.FC = () => {
                            const modal = useModal();
                            const {mutateAsync: importContent} = useImportContent();
                            const [uploading, setUploading] = useState(false);
                            const handleError = useHandleError();

                          Function onThemeUpload has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              const onThemeUpload = async (file: File) => {
                                  const themeFileName = file?.name.replace(/\.zip$/, '');
                                  const existingThemeNames = themes.map(t => t.name);
                                  if (isDefaultOrLegacyTheme({name: themeFileName})) {
                                      NiceModal.show(ConfirmationModal, {
                          Severity: Minor
                          Found in apps/admin-x-settings/src/components/settings/site/ThemeModal.tsx - About 1 hr to fix

                            Function import has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                                async import(quantity) {
                                    if (quantity === 0) {
                                        return;
                                    }
                            
                            
                            Severity: Minor
                            Found in ghost/data-generator/lib/importers/EmailRecipientsImporter.js - About 1 hr 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 identifyUser has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export async function identifyUser(user) {
                                // Return early if window.posthog doesn't exist
                                if (!isPosthogLoaded()) {
                                    return;
                                }
                            Severity: Minor
                            Found in ghost/admin/app/utils/analytics.js - About 1 hr 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 onExcerptKeydown has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                                @action
                                onExcerptKeydown(event) {
                                    // move cursor to the title on
                                    // - Shift+Tab (handled by the browser)
                                    // - Arrow Up/Left when input is empty or caret at start of input
                            Severity: Minor
                            Found in ghost/admin/app/components/gh-koenig-editor-lexical.js - About 1 hr 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 getMRR has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                                getMRR({interval, amount, status = null, canceled = false, discount = null}) {
                                    if (status === 'trialing') {
                                        return 0;
                                    }
                                    if (status === 'incomplete') {
                            Severity: Minor
                            Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 hr 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 prepareError has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                            module.exports.prepareError = function prepareError(err, req, res, next) {
                                debug(err);
                            
                                if (Array.isArray(err)) {
                                    err = err[0];
                            Severity: Minor
                            Found in ghost/mw-error-handler/lib/mw-error-handler.js - About 1 hr 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 _getSubscriptionCheckoutData has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                                async _getSubscriptionCheckoutData(body) {
                                    const tierId = body.tierId;
                                    const offerId = body.offerId;
                            
                                    let cadence = body.cadence;
                            Severity: Minor
                            Found in ghost/members-api/lib/controllers/RouterController.js - About 1 hr 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 serializeMember has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function serializeMember(member, options) {
                                const json = member.toJSON ? member.toJSON(options) : member;
                            
                                const comped = json.status === 'comped';
                            
                            

                            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