TryGhost/Ghost

View on GitHub

Showing 1,756 of 3,886 total issues

File member.js has 396 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const ghostBookshelf = require('./base');
const uuid = require('uuid');
const _ = require('lodash');
const config = require('../../shared/config');
const {gravatar} = require('../lib/image');
Severity: Minor
Found in ghost/core/core/server/models/member.js - About 5 hrs to fix

    Function checkoutSessionEvent has 136 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async checkoutSessionEvent(session) {
            if (session.mode === 'setup') {
                const setupIntent = await this.api.getSetupIntent(session.setup_intent);
                const member = await this.deps.memberRepository.get({
                    customer_id: setupIntent.metadata.customer_id
    Severity: Major
    Found in ghost/stripe/lib/WebhookController.js - About 5 hrs to fix

      Function fetchQueryStrData has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          fetchQueryStrData(qs = '') {
              const qsParams = new URLSearchParams(qs);
              const data = {
                  site: {
                      plans: {}
      Severity: Minor
      Found in apps/portal/src/App.js - About 5 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 create has 130 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async create(data, options = {}) {
              if (!this._stripeAPIService.configured && (data.stripe_prices || data.monthly_price || data.yearly_price)) {
                  throw new UpdateCollisionError({
                      message: 'The requested functionality requires Stripe to be configured. See https://ghost.org/integrations/stripe/',
                      code: 'STRIPE_NOT_CONFIGURED'
      Severity: Major
      Found in ghost/members-api/lib/repositories/ProductRepository.js - About 5 hrs to fix

        File Modal.tsx has 383 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import {useModal} from '@ebay/nice-modal-react';
        import clsx from 'clsx';
        import React, {useEffect, useState} from 'react';
        import useGlobalDirtyState from '../../hooks/useGlobalDirtyState';
        import {confirmIfDirty} from '../../utils/modals';
        Severity: Minor
        Found in apps/admin-x-design-system/src/global/modal/Modal.tsx - About 5 hrs to fix

          Function draw has 128 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Chart.elements.Rectangle.prototype.draw = function () {
              var ctx = this._chart.ctx;
              var vm = this._view;
              var left, right, top, bottom, borderSkipped, radius;
          
          
          Severity: Major
          Found in ghost/admin/app/components/dashboard/charts/paid-mix.js - About 5 hrs to fix

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

            module.exports = function (Bookshelf) {
                const insertAction = (data, options) => {
                    // CASE: model does not support action for target event
                    if (!data) {
                        return;
            Severity: Major
            Found in ghost/core/core/server/models/base/plugins/actions.js - About 5 hrs to fix

              Function updateMockedData has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

                  updateMockedData({days}) {
                      const generateDays = days;
                      const startDate = new Date();
                      startDate.setDate(startDate.getDate() - generateDays + 1);
              
              
              Severity: Minor
              Found in ghost/admin/app/services/dashboard-mocks.js - About 5 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 permissible has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

                  permissible: async function permissible(userModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
                      const self = this;
                      const userModel = userModelOrId;
                      let origArgs;
              
              
              Severity: Minor
              Found in ghost/core/core/server/models/user.js - About 5 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 getTitle has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

              function getTitle(data, root, options = {}) {
                  const context = root ? root.context : null;
                  const siteTitle = settingsCache.get('title') || '';
                  const pagination = root ? root.pagination : null;
              
              
              Severity: Minor
              Found in ghost/core/core/frontend/meta/title.js - About 5 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 Modal has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
              Open

              const Modal: React.FC<ModalProps> = ({
                  size = 'md',
                  width,
                  height,
                  testId,
              Severity: Minor
              Found in apps/admin-x-design-system/src/global/modal/Modal.tsx - About 5 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 chartOptions has 125 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  get chartOptions() {
                      const that = this;
                      let activeDays = this.dashboardStats.chartDays;
                      let barColor = this.feature.nightShift ? 'rgba(200, 204, 217, 0.25)' : 'rgba(200, 204, 217, 0.65)';
              
              
              Severity: Major
              Found in ghost/admin/app/components/dashboard/charts/anchor-attribution.js - About 5 hrs to fix

                exports has 38 functions (exceeds 20 allowed). Consider refactoring.
                Open

                module.exports = class StripeAPI {
                    /**
                     * StripeAPI
                     */
                    constructor(deps) {
                Severity: Minor
                Found in ghost/stripe/lib/StripeAPI.js - About 5 hrs to fix

                  Function PinturaModal has 125 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const PinturaModal = NiceModal.create(() => {
                      const {updateRoute} = useRouting();
                      const modal = NiceModal.useModal();
                      const [enabled, setEnabled] = useState(false);
                      const [uploadingState, setUploadingState] = useState({

                    Function create has 123 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        async create(data, options) {
                            if (!options) {
                                options = {};
                            }
                    
                    
                    Severity: Major
                    Found in ghost/members-api/lib/repositories/MemberRepository.js - About 4 hrs to fix

                      Function exports has a Cognitive Complexity of 33 (exceeds 5 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: Minor
                      Found in ghost/members-csv/lib/parse.js - About 4 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 onUpdated has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                      Open

                          onUpdated: function onUpdated(model, options) {
                              ghostBookshelf.Model.prototype.onUpdated.apply(this, arguments);
                      
                              model.statusChanging = model.get('status') !== model.previous('status');
                              model.isPublished = model.get('status') === 'published';
                      Severity: Minor
                      Found in ghost/core/core/server/models/post.js - About 4 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 ping has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function ping(post) {
                          let message;
                          let title;
                          let author;
                          let description;
                      Severity: Minor
                      Found in ghost/core/core/server/services/slack.js - About 4 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 chartOptions has 121 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          get chartOptions() {
                              let that = this;
                              let ticksY = {display: false};
                              let totalCadence = this.dashboardStats.paidMembersByCadence.month + this.dashboardStats.paidMembersByCadence.year;
                              let minTickValue = -(Math.round(this.dashboardStats.paidMembersByCadence.month / totalCadence * 100));
                      Severity: Major
                      Found in ghost/admin/app/components/dashboard/charts/paid-mix.js - About 4 hrs to fix

                        GhPostSettingsMenu has 37 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        @classic
                        @tagName('')
                        export default class GhPostSettingsMenu extends Component {
                            @service feature;
                            @service store;
                        Severity: Minor
                        Found in ghost/admin/app/components/gh-post-settings-menu.js - About 4 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language