TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function MigrationToolsImport has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const MigrationToolsImport: React.FC = () => {
    const {updateRoute} = useRouting();

    const handleImportContent = () => {
        NiceModal.show(UniversalImportModal);

    Function testRows has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        const testRows = (noOfRows: number) => {
            const data: DynamicTableRow[] = [];
            for (let i = 0; i < noOfRows; i++) {
                data.push(
                    {
    Severity: Minor
    Found in apps/admin-x-demo/src/ListPage.tsx - About 1 hr to fix

      Function getAttributionFromContext has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          async getAttributionFromContext(context) {
              if (!context || !this.isTrackingEnabled) {
                  return null;
              }
      
      
      Severity: Minor
      Found in ghost/member-attribution/lib/MemberAttributionService.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 didReceiveAttrs has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          didReceiveAttrs() {
              super.didReceiveAttrs(...arguments);
      
              let date = this.date;
              let time = this.time;
      Severity: Minor
      Found in ghost/admin/app/components/gh-date-time-picker.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 _updateGrow has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          _updateGrow(settings) {
              const change = Math.round(Math.random() * (settings.growRate - settings.shrinkOffset));
      
              if (settings.growPeriod) {
                  settings.growCount += 1;
      Severity: Minor
      Found in ghost/admin/app/services/dashboard-mocks.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 setTwitterUrl has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          @action
          setTwitterUrl(event) {
              const {model, modelProperty} = this.args;
      
              const newUrl = event.target.value;
      Severity: Minor
      Found in ghost/admin/app/components/gh-twitter-url-input.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 postBuild has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          postBuild: function (results) {
              const fs = this.project.require('fs-extra');
              const walkSync = this.project.require('walk-sync');
      
              const assetsOut = path.join(path.dirname(require.resolve('ghost')), `core/built/admin`);
      Severity: Minor
      Found in ghost/admin/lib/asset-delivery/index.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 minify has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          async minify(globs, options) {
              debug('Begin', globs);
              const destinations = Object.keys(globs);
              const minifiedFiles = [];
      
      
      Severity: Minor
      Found in ghost/minifier/lib/Minifier.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 setComplimentarySubscription has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          async setComplimentarySubscription(data, options = {}) {
              if (!options.transacting) {
                  return this._Member.transaction((transacting) => {
                      return this.setComplimentarySubscription(data, {
                          ...options,
      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 createCheckoutSession has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          async createCheckoutSession(priceId, customer, options) {
              const metadata = options.metadata || undefined;
              const customerId = customer ? customer.id : undefined;
              const customerEmail = customer ? customer.email : options.customerEmail;
      
      
      Severity: Minor
      Found in ghost/stripe/lib/StripeAPI.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 bulkDestroy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          bulkDestroy: async function bulkDestroy(ids, tableName, options) {
              if (tableName === this.prototype.tableName) {
                  if (labs.isSet('collectionsCard')) {
                      // get count of published posts to be destroyed before they no longer exist to count
                      const deletedPublishedCount = await this.query((qb) => {
      Severity: Minor
      Found in ghost/core/core/server/models/post.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 permissible has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          permissible: function permissible(roleModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
              // If we passed in an id instead of a model, get the model
              // then check the permissions
              if (_.isNumber(roleModelOrId) || _.isString(roleModelOrId)) {
                  // Get the actual role model
      Severity: Minor
      Found in ghost/core/core/server/models/role.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 createCheckoutSetupSession has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          async createCheckoutSetupSession(req, res) {
              const identity = req.body.identity;
      
              if (!identity) {
                  res.writeHead(400);
      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 stripe_plans has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

              async stripe_plans(model, options) {
                  const plans = JSON.parse(model.get('value'));
                  for (const plan of plans) {
                      // Stripe plans used to be allowed (and defaulted to!) 0 amount plans
                      // this causes issues to people importing from older versions of Ghost
      Severity: Minor
      Found in ghost/core/core/server/models/settings.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 forPost has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      const forPost = (attrs, options) => {
          if (options && options.withRelated) {
              options.withRelated.forEach((relation) => {
                  if (relation === 'tags' && attrs.tags) {
                      attrs.tags = attrs.tags.map(tag => forTag(tag));

      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 apiKeyAuthenticateWithToken has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      const authenticateWithToken = async function apiKeyAuthenticateWithToken(originalUrl, token, ignoreMaxAge) {
          const decoded = jwt.decode(token, {complete: true});
          const jwtValidationOptions = ignoreMaxAge ? _.omit(JWT_OPTIONS_DEFAULTS, 'maxAge') : JWT_OPTIONS_DEFAULTS;
      
          if (!decoded || !decoded.header) {
      Severity: Minor
      Found in ghost/core/core/server/services/auth/api-key/admin.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 validation has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      const validation = function ({type}) {
          // if we finish the data/importer logic, we forward the request to the specified importer
      
          /**
           * @param {import('express').Request} req
      Severity: Minor
      Found in ghost/core/core/server/web/api/middleware/upload.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 getTotalMembersOnDatesInRange has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          async getTotalMembersOnDatesInRange({days, totalMembers, siteTimezone}) {
              const startOfRange = moment.tz(siteTimezone).subtract(days - 1, 'days').startOf('day').utc().format(dateFormat);
              const tzOffsetMins = moment.tz(siteTimezone).utcOffset();
      
              let result;
      Severity: Minor
      Found in ghost/core/core/server/services/members/stats/MembersStats.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 init has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          async init() {
              const stripeService = require('../stripe');
              const createMembersApiInstance = require('./api');
              const env = config.get('env');
      
      
      Severity: Minor
      Found in ghost/core/core/server/services/members/service.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 _onResourceUpdated has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          async _onResourceUpdated(type, model) {
              debug('_onResourceUpdated', type);
      
              const resourceConfig = _.find(this.resourcesConfig, {type: type});
      
      
      Severity: Minor
      Found in ghost/core/core/server/services/url/Resources.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

      Severity
      Category
      Status
      Source
      Language