TryGhost/Ghost

View on GitHub

Showing 1,756 of 3,886 total issues

Function ping has 99 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function ping(post) {
    let message;
    let title;
    let author;
    let description;
Severity: Major
Found in ghost/core/core/server/services/slack.js - About 3 hrs to fix

    Function AddNewsletterModal has 98 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const AddNewsletterModal: React.FC<RoutingModalProps> = () => {
        const modal = useModal();
        const {updateRoute} = useRouting();
        const handleError = useHandleError();
    
    

      File actions.ts has 330 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import {AddComment, Comment, CommentsOptions, EditableAppContext} from './AppContext';
      import {AdminApi} from './utils/adminApi';
      import {GhostApi} from './utils/api';
      import {Page} from './pages';
      
      
      Severity: Minor
      Found in apps/comments-ui/src/actions.ts - About 3 hrs to fix

        Function pipeline has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        const pipeline = (apiController, apiUtils, apiType) => {
            if (controllerMap.has(apiController)) {
                return controllerMap.get(apiController);
            }
        
        
        Severity: Minor
        Found in ghost/api-framework/lib/pipeline.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 InviteUserModal has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        const InviteUserModal = NiceModal.create(() => {
            const modal = NiceModal.useModal();
            const rolesQuery = useBrowseRoles();
            const assignableRolesQuery = useBrowseRoles({
                searchParams: {limit: 'all', permissions: 'assign'}

        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 27 (exceeds 5 allowed). Consider refactoring.
        Open

        export const getLinkTarget = (action: Action): InternalLink | ExternalLink | undefined => {
            let resourceType = action.resource_type;
        
            if (action.event !== 'deleted') {
                switch (action.resource_type) {
        Severity: Minor
        Found in apps/admin-x-framework/src/api/actions.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 handleImageSizes has 97 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function handleImageSizes(req, res, next) {
            // In admin we need to read images and calculate the average color (blocked by CORS otherwise)
            res.setHeader('Access-Control-Allow-Origin', '*');
        
            if (!SIZE_PATH_REGEX.test(req.url)) {
        Severity: Major
        Found in ghost/core/core/frontend/web/middleware/handle-image-sizes.js - About 3 hrs to fix

          Function EmbedSignupFormModal has 97 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const EmbedSignupFormModal = NiceModal.create(() => {
              let i18nEnabled = false;
          
              const [selectedColor, setSelectedColor] = useState<string>('#08090c');
              const [selectedLabels, setSelectedLabels] = useState<SelectedLabelTypes[]>([]);

            Function setupSiteApp has 96 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = function setupSiteApp(routerConfig) {
                debug('Site setup start', routerConfig);
            
                const siteApp = express('site');
            
            
            Severity: Major
            Found in ghost/core/core/frontend/web/site.js - About 3 hrs to fix

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

              export default class App extends React.Component {
                  constructor(props) {
                      super(props);
              
                      this.setupCustomTriggerButton(props);
              Severity: Minor
              Found in apps/portal/src/App.js - About 3 hrs to fix

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

                    async updateSubscription(data, options) {
                        const sharedOptions = {
                            transacting: options ? options.transacting : null
                        };
                        if (!this._stripeAPIService.configured) {
                Severity: Minor
                Found in ghost/members-api/lib/repositories/MemberRepository.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 SignupOptions has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
                Open

                }> = ({localSettings, updateSetting, localTiers, updateTier, errors, setError}) => {
                    const {config} = useGlobalData();
                    const hasPortalImprovements = useFeatureFlag('portalImprovements');
                    const [membersSignupAccess, portalName, portalSignupTermsHtml, portalSignupCheckboxRequired, portalPlansJson, portalDefaultPlan] = getSettingValues(
                        localSettings, ['members_signup_access', 'portal_name', 'portal_signup_terms_html', 'portal_signup_checkbox_required', 'portal_plans', 'portal_default_plan']

                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

                File middleware.js has 322 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 3 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language