TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function dummyCards has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    const dummyCards = (noOfCards: number) => {
        const cards = [];

        for (let i = 0; i < noOfCards; i++) {
            cards.push(
Severity: Major
Found in apps/admin-x-demo/src/ListPage.tsx - About 2 hrs to fix

    File pages.js has 268 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const models = require('../../models');
    const tpl = require('@tryghost/tpl');
    const errors = require('@tryghost/errors');
    const getPostServiceInstance = require('../../services/posts/posts-service');
    const ALLOWED_INCLUDES = ['tags', 'authors', 'authors.roles', 'tiers', 'count.signups', 'count.paid_conversions', 'post_revisions', 'post_revisions.author'];
    Severity: Minor
    Found in ghost/core/core/server/api/endpoints/pages.js - About 2 hrs to fix

      Function chartData has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          get chartData() {
              const totalCadence = this.dashboardStats.paidMembersByCadence.month + this.dashboardStats.paidMembersByCadence.year;
              const monthlyPercentage = Math.round(this.dashboardStats.paidMembersByCadence.month / totalCadence * 100);
              const annualPercentage = Math.round(this.dashboardStats.paidMembersByCadence.year / totalCadence * 100);
              const barThickness = 5;
      Severity: Minor
      Found in ghost/admin/app/components/dashboard/charts/paid-mix.js - About 2 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 getCustomerIdByEmail has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          async getCustomerIdByEmail(email) {
              await this._searchRateLimitBucket.throttle();
              try {
                  const result = await this._stripe.customers.search({
                      query: `email:"${email}"`,
      Severity: Minor
      Found in ghost/stripe/lib/StripeAPI.js - About 2 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 handleSetupEvent has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          async handleSetupEvent(session) {
              const setupIntent = await this.api.getSetupIntent(session.setup_intent);
      
              const memberRepository = this.deps.memberRepository;
              const member = await memberRepository.get({
      Severity: Minor
      Found in ghost/stripe/lib/services/webhook/CheckoutSessionEventService.js - About 2 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 populateProductsAndPrices has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          async populateProductsAndPrices(options) {
              if (!options) {
                  return this.models.Product.transaction((transacting) => {
                      return this.populateProductsAndPrices({transacting});
                  });
      Severity: Minor
      Found in ghost/stripe/lib/StripeMigrations.js - About 2 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 createCheckoutSession has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          async createCheckoutSession(req, res) {
              const type = req.body.type ?? 'subscription';
              const metadata = req.body.metadata ?? {};
              const identity = req.body.identity;
              const membersEnabled = true;
      Severity: Minor
      Found in ghost/members-api/lib/controllers/RouterController.js - About 2 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 onSaving has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          onSaving: function onSaving(newPage, attr, options) {
              const self = this;
              const tasks = [];
              let passwordValidation = {};
      
      
      Severity: Minor
      Found in ghost/core/core/server/models/user.js - About 2 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 up has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          async function up(knex) {
              logging.info('Populating members_paid_subscription_events from members_stripe_customers_subscriptions');
              const allSubscriptions = await knex
                  .select(
                      'c.member_id',

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

      function getOgImage(data) {
          const context = data.context ? data.context : null;
          const contextObject = getContextObject(data, context);
      
          if (_.includes(context, 'home')) {
      Severity: Minor
      Found in ghost/core/core/frontend/meta/og-image.js - About 2 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 tiers has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = function tiers(options = {}) {
          options = options || {};
          options.hash = options.hash || {};
      
          const separator = isString(options.hash.separator) ? options.hash.separator : ', ';
      Severity: Minor
      Found in ghost/core/core/frontend/helpers/tiers.js - About 2 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 getTwitterImage has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      function getTwitterImage(data) {
          const context = data.context ? data.context : null;
          const contextObject = getContextObject(data, context);
      
          if (_.includes(context, 'home')) {
      Severity: Minor
      Found in ghost/core/core/frontend/meta/twitter-image.js - About 2 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 entryController has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = function entryController(req, res, next) {
          debug('entryController', res.routerOptions);
      
          return dataService.entryLookup(req.path, res.routerOptions, res.locals)
              .then(function then(lookup) {
      Severity: Minor
      Found in ghost/core/core/frontend/services/routing/controllers/entry.js - About 2 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 intercept has a Cognitive Complexity of 18 (exceeds 5 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 2 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 handleOfferQuery has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          async handleOfferQuery({site, offerId, member = this.state.member}) {
              const {portal_button: portalButton} = site;
              removePortalLinkFromUrl();
              if (!isPaidMember({member})) {
                  try {
      Severity: Minor
      Found in apps/portal/src/App.js - About 2 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 App has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

      const App: React.FC<AppProps> = ({scriptTag}) => {
          const options = useOptions(scriptTag);
          const [state, setFullState] = useState<EditableAppContext>({
              initStatus: 'running',
              member: null,
      Severity: Minor
      Found in apps/comments-ui/src/App.tsx - About 2 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 import has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async import(quantity) {
              if (quantity === 0) {
                  return;
              }
      
      
      Severity: Major
      Found in ghost/data-generator/lib/importers/EmailRecipientsImporter.js - About 2 hrs to fix

        Function generate has 60 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            generate() {
                const id = this.fastFakeObjectId();
        
                let newsletter;
                if (this.newsletters.length === 0) {
        Severity: Major
        Found in ghost/data-generator/lib/importers/EmailsImporter.js - About 2 hrs to fix

          Function _uploadFile has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _uploadFile: task(function* (tracker, file, index) {
                  let ajax = this.ajax;
                  let formData = this._getFormData(file);
                  let url = `${ghostPaths().apiRoot}${this.uploadUrl}`;
                  let metadata = null;
          Severity: Major
          Found in ghost/admin/app/components/gh-uploader.js - About 2 hrs to fix

            Function chartOptions has 60 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                get chartOptions() {
                    let chartTitle = 'Free signups';
                    if (this.args.sortColumn === 'signups') {
                        chartTitle = 'Free signups';
                    } else {
              Severity
              Category
              Status
              Source
              Language