TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Anchor has 31 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class Anchor extends Component {
    @service dashboardStats;
    @service feature;
    @tracked chartDisplay = 'mrr';
    @tracked resizing = false;
Severity: Minor
Found in ghost/admin/app/components/dashboard/charts/anchor-attribution.js - About 3 hrs to fix

    File MemberBREADService.js has 323 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const errors = require('@tryghost/errors');
    const logging = require('@tryghost/logging');
    const tpl = require('@tryghost/tpl');
    const moment = require('moment');
    
    
    Severity: Minor
    Found in ghost/members-api/lib/services/MemberBREADService.js - About 3 hrs to fix

      Function getIcon has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          getIcon(event) {
              let icon;
      
              if (event.type === 'login_event') {
                  icon = 'logged-in';
      Severity: Minor
      Found in ghost/admin/app/helpers/parse-member-event.js - About 3 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 getReferrerDetails has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          getReferrerDetails(history) {
              // Empty history will return null as it means script is not loaded
              if (history.length === 0) {
                  return {
                      referrerSource: null,
      Severity: Minor
      Found in ghost/member-attribution/lib/ReferrerTranslator.js - About 3 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 getLinkTarget has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      function getLinkTarget(ev) {
          let resourceType = ev.resource_type;
      
          if (ev.event !== 'deleted') {
              switch (ev.resource_type) {
      Severity: Minor
      Found in ghost/admin/app/helpers/parse-history-event.js - About 3 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 error has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

              error(error, transition) {
                  // unauthorized errors are already handled in the ajax service
                  if (isUnauthorizedError(error)) {
                      return false;
                  }
      Severity: Minor
      Found in ghost/admin/app/routes/application.js - About 3 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 a Cognitive Complexity of 26 (exceeds 5 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: Minor
      Found in ghost/admin/app/components/dashboard/charts/paid-mix.js - About 3 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 a Cognitive Complexity of 26 (exceeds 5 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: Minor
      Found in ghost/members-api/lib/repositories/ProductRepository.js - About 3 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 post has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      const post = (attrs, frame) => {
          const columns = frame && frame.options && frame.options.columns || null;
          const fields = frame && frame.original && frame.original.query && frame.original.query.fields || null;
      
          if (localUtils.isContentAPI(frame)) {

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

      const createSessionFromMagicLink = async function createSessionFromMagicLink(req, res, next) {
          if (!req.url.includes('token=')) {
              return next();
          }
      
      
      Severity: Minor
      Found in ghost/core/core/server/services/members/middleware.js - About 3 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 AddRecommendationModal has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      const AddRecommendationModal: React.FC<RoutingModalProps & AddRecommendationModalProps> = ({searchParams, recommendation, animate}) => {
          const [enterPressed, setEnterPressed] = useState(false);
          const modal = useModal();
          const {updateRoute} = useRouting();
          const {mutateAsync: checkRecommendation} = useCheckRecommendation();

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

      function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}: {siteUrl: string, apiUrl: string, apiKey: string}) {
          const apiPath = 'members/api';
      
          function endpointFor({type, resource, params = ''}: {type: string, resource: string, params?: string}) {
              if (type === 'members') {
      Severity: Minor
      Found in apps/comments-ui/src/utils/api.ts - About 3 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 93 lines of code (exceeds 25 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',

        Function fetchQueryStrData has 93 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            fetchQueryStrData(qs = '') {
                const qsParams = new URLSearchParams(qs);
                const data = {
                    site: {
                        plans: {}
        Severity: Major
        Found in apps/portal/src/App.js - About 3 hrs to fix

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

              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-breakdown.js - About 3 hrs to fix

            File test-fixtures.js has 320 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /* eslint-disable no-unused-vars*/
            import {getFreeProduct, getMemberData, getOfferData, getPriceData, getProductData, getSiteData, getSubscriptionData, getNewsletterData} from './fixtures-generator';
            
            export const transformTierFixture = [
                getFreeProduct({
            Severity: Minor
            Found in apps/portal/src/utils/test-fixtures.js - About 3 hrs to fix

              Consider simplifying this complex logical expression.
              Open

                      if (!member) {
                          const metadataName = _.get(session, 'metadata.name');
                          const metadataNewsletters = _.get(session, 'metadata.newsletters');
                          const attribution = {
                              id: session.metadata.attribution_id ?? null,
              Severity: Critical
              Found in ghost/stripe/lib/services/webhook/CheckoutSessionEventService.js - About 3 hrs to fix

                File import-manager.js has 319 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                const _ = require('lodash');
                const fs = require('fs-extra');
                const path = require('path');
                const os = require('os');
                const glob = require('glob');
                Severity: Minor
                Found in ghost/core/core/server/data/importer/import-manager.js - About 3 hrs to fix

                  Function forceStripeSubscriptionToProduct has 91 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      async forceStripeSubscriptionToProduct(data, options) {
                          if (!this._stripeAPIService.configured) {
                              throw new DataImportError({
                                  message: tpl(messages.noStripeConnection, {action: 'force subscription to product'})
                              });
                  Severity: Major
                  Found in ghost/members-importer/lib/MembersCSVImporterStripeUtils.js - About 3 hrs to fix

                    Function FirstpromoterModal has 91 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const FirstpromoterModal = NiceModal.create(() => {
                        const {updateRoute} = useRouting();
                    
                        const {settings} = useGlobalData();
                        const {mutateAsync: editSettings} = useEditSettings();
                      Severity
                      Category
                      Status
                      Source
                      Language