TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

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

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

      Post = ghostBookshelf.Model.extend({
      
          tableName: 'posts',
      
          actionsCollectCRUD: true,
      Severity: Minor
      Found in ghost/core/core/server/models/post.js - About 4 hrs to fix

        Function updateSubscription has 119 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async updateSubscription(req, res) {
                try {
                    const identity = req.body.identity;
                    const subscriptionId = req.params.id;
                    const cancelAtPeriodEnd = req.body.cancel_at_period_end;
        Severity: Major
        Found in ghost/members-api/lib/controllers/MemberController.js - About 4 hrs to fix

          File PaymentsService.js has 365 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          const logging = require('@tryghost/logging');
          const DomainEvents = require('@tryghost/domain-events');
          const {TierCreatedEvent, TierPriceChangeEvent, TierNameChangeEvent} = require('@tryghost/tiers');
          const OfferCreatedEvent = require('@tryghost/members-offers').events.OfferCreatedEvent;
          const {BadRequestError} = require('@tryghost/errors');
          Severity: Minor
          Found in ghost/payments/lib/PaymentsService.js - About 4 hrs to fix

            Function handleAudioPlayer has 119 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                const handleAudioPlayer = function (audioElementContainer) {
                    const audioPlayerContainer = audioElementContainer.querySelector('.kg-audio-player-container');
                    const playIconContainer = audioElementContainer.querySelector('.kg-audio-play-icon');
                    const pauseIconContainer = audioElementContainer.querySelector('.kg-audio-pause-icon');
                    const seekSlider = audioElementContainer.querySelector('.kg-audio-seek-slider');
            Severity: Major
            Found in ghost/core/core/frontend/src/cards/js/audio.js - About 4 hrs to fix

              Function create has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
              Open

                  async create(data, options) {
                      if (!options) {
                          options = {};
                      }
              
              
              Severity: Minor
              Found in ghost/members-api/lib/repositories/MemberRepository.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 Connect has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
              Open

              const Connect: React.FC = () => {
                  const [submitEnabled, setSubmitEnabled] = useState(false);
                  const [token, setToken] = useState('');
                  const [testMode, setTestMode] = useState(false);
                  const [error, setError] = useState('');

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

              const ViewContainer: React.FC<ViewContainerProps> = ({
                  type,
                  title,
                  firstOnPage = true,
                  headerContent,
              Severity: Minor
              Found in apps/admin-x-design-system/src/global/layout/ViewContainer.tsx - 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 validateData has 118 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              _private.validateData = function validateData(object) {
                  if (!Object.prototype.hasOwnProperty.call(object, 'data')) {
                      return object;
                  }
              
              
              Severity: Major
              Found in ghost/core/core/server/services/route-settings/validate.js - About 4 hrs to fix

                File activitypub.ts has 359 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                export type Actor = any;
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                export type Activity = any;
                
                
                Severity: Minor
                Found in apps/admin-x-activitypub/src/api/activitypub.ts - About 4 hrs to fix

                  Function OfferPageStyles has 115 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const OfferPageStyles = () => {
                      return `
                  .gh-portal-offer {
                      padding-bottom: 0;
                      overflow: unset;
                  Severity: Major
                  Found in apps/portal/src/components/pages/OfferPage.js - About 4 hrs to fix

                    File middleware.js has 358 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    const crypto = require('crypto');
                    const _ = require('lodash');
                    const logging = require('@tryghost/logging');
                    const membersService = require('./service');
                    const emailSuppressionList = require('../email-suppression-list');
                    Severity: Minor
                    Found in ghost/core/core/server/services/members/middleware.js - About 4 hrs to fix

                      Function createSessionService has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                      Open

                      module.exports = function createSessionService({
                          getSession,
                          findUserById,
                          getOriginOfRequest,
                          getSettingsCache,
                      Severity: Minor
                      Found in ghost/session-service/lib/session-service.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 sendMagicLink has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                      Open

                          async sendMagicLink(req, res) {
                              const {email, honeypot, autoRedirect} = req.body;
                              let {emailType, redirect} = req.body;
                      
                              let referer = req.get('referer');
                      Severity: Minor
                      Found in ghost/members-api/lib/controllers/RouterController.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 edit has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                      Open

                          edit: function (data, unfilteredOptions) {
                              const options = this.filterOptions(unfilteredOptions, 'edit');
                              const self = this;
                      
                              if (!Array.isArray(data)) {
                      Severity: Minor
                      Found in ghost/core/core/server/models/settings.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 DesignModal has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
                      Open

                      const DesignModal: React.FC = () => {
                          const {settings, siteData} = useGlobalData();
                          const {mutateAsync: editSettings} = useEditSettings();
                          const {data: {posts: [latestPost]} = {posts: []}} = useBrowsePosts({
                              searchParams: {
                      Severity: Minor
                      Found in apps/admin-x-settings/src/components/settings/site/DesignModal.tsx - 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

                      Severity
                      Category
                      Status
                      Source
                      Language