TryGhost/Ghost

View on GitHub

Showing 1,756 of 3,886 total issues

Function NavigationModal has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const NavigationModal = NiceModal.create(() => {
    const modal = useModal();
    const {updateRoute} = useRouting();
    const {
        localSettings,

    Function createCustomNotification has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        async createCustomNotification(notification) {
            if (!notification || !notification.messages || notification.messages.length === 0) {
                debug(`Skipping notification creation as there are no messages to process`);
                return;
            }
    Severity: Minor
    Found in ghost/update-check-service/lib/UpdateCheckService.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 init has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        async init() {
            this.Suppression = models.Suppression;
            const handleEvent = reason => async (event) => {
                try {
                    if (reason === 'bounce') {

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

    function addTableColumn(tableName, tableBuilder, columnName, columnSpec = schema[tableName][columnName]) {
        let column;
    
        // creation distinguishes between text with fieldtype, string with maxlength and all others
        if (columnSpec.type === 'text' && Object.prototype.hasOwnProperty.call(columnSpec, 'fieldtype')) {
    Severity: Minor
    Found in ghost/core/core/server/data/schema/commands.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 unsubscribeController has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = async function unsubscribeController(req, res) {
        debug('unsubscribeController');
    
        const {query} = url.parse(req.url, true);
    
    
    Severity: Minor
    Found in ghost/core/core/frontend/services/routing/controllers/unsubscribe.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 useNavigationEditor has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    const useNavigationEditor = ({items, setItems}: {
        items: NavigationItem[];
        setItems: (newItems: NavigationItem[]) => void;
    }): NavigationEditor => {
        const hasNewItem = (newItem: NavigationItem) => Boolean((newItem.label && !newItem.label.match(/^\s*$/)) || newItem.url !== '/');
    Severity: Minor
    Found in apps/admin-x-settings/src/hooks/site/useNavigationEditor.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 setupGhostApi has a Cognitive Complexity of 19 (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 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 TextField has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    const TextField: React.FC<TextFieldProps> = ({
        type = 'text',
        inputRef,
        title,
        hideTitle,
    Severity: Minor
    Found in apps/admin-x-design-system/src/global/form/TextField.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

    File paid-breakdown.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* globals Chart */
    
    import Component from '@glimmer/component';
    import moment from 'moment-timezone';
    import {action} from '@ember/object';
    Severity: Minor
    Found in ghost/admin/app/components/dashboard/charts/paid-breakdown.js - About 2 hrs to fix

      Function populateMembersMonthlyPriceIdSettings has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async populateMembersMonthlyPriceIdSettings(options) {
              if (!options) {
                  return this.models.Product.transaction((transacting) => {
                      return this.populateMembersMonthlyPriceIdSettings({transacting});
                  });
      Severity: Major
      Found in ghost/stripe/lib/StripeMigrations.js - About 2 hrs to fix

        Function exports has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = createIrreversibleMigration(async (knex) => {
            if (!DatabaseInfo.isSQLite(knex)) {
                return logging.warn('Skipping adding "on delete cascade" - database is not SQLite3');
            }
        
        

          Function RecommendationsPage has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const RecommendationsPage = () => {
              const {api, site, pageData, t, onAction} = useContext(AppContext);
              const {title, icon} = site;
              const {recommendations_enabled: recommendationsEnabled = false} = site;
              const [recommendations, setRecommendations] = useState(null);
          Severity: Major
          Found in apps/portal/src/components/pages/RecommendationsPage.js - About 2 hrs to fix

            Function useDefaultRecipientsOptions has 64 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const useDefaultRecipientsOptions = (selectedOption: string, defaultEmailRecipientsFilter?: string | null) => {
                const tiers = useFilterableApi<Tier, 'tiers', 'name'>({path: '/tiers/', filterKey: 'name', responseKey: 'tiers'});
                const labels = useFilterableApi<Label, 'labels', 'name'>({path: '/labels/', filterKey: 'name', responseKey: 'labels'});
                const offers = useFilterableApi<Offer, 'offers', 'name'>({path: '/offers/', filterKey: 'name', responseKey: 'offers'});
            
            

              File parse-member-event.js has 273 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import Helper from '@ember/component/helper';
              import moment from 'moment-timezone';
              import {getNonDecimal, getSymbol} from 'ghost-admin/utils/currency';
              import {ghPluralize} from 'ghost-admin/helpers/gh-pluralize';
              import {inject as service} from '@ember/service';
              Severity: Minor
              Found in ghost/admin/app/helpers/parse-member-event.js - About 2 hrs to fix

                Function populateMembersYearlyPriceIdSettings has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    async populateMembersYearlyPriceIdSettings(options) {
                        if (!options) {
                            return this.models.Product.transaction((transacting) => {
                                return this.populateMembersYearlyPriceIdSettings({transacting});
                            });
                Severity: Major
                Found in ghost/stripe/lib/StripeMigrations.js - About 2 hrs to fix

                  Function result has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      const result = keys.reduce((obj, method) => {
                          const apiImpl = _.cloneDeep(apiController)[method];
                  
                          Object.freeze(apiImpl.headers);
                  
                  
                  Severity: Major
                  Found in ghost/api-framework/lib/pipeline.js - About 2 hrs to fix

                    Function createCheckoutSession has 63 lines of code (exceeds 25 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: Major
                    Found in ghost/members-api/lib/controllers/RouterController.js - About 2 hrs to fix

                      Function add has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          add(apiConfig, frame, options = {add: true}) {
                              debug('add');
                      
                              if (_.get(frame,'options.source')) {
                                  const html = frame.data.pages[0].html;
                      Severity: Major
                      Found in ghost/core/core/server/api/endpoints/utils/serializers/input/pages.js - About 2 hrs to fix

                        Function add has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            add(apiConfig, frame, options = {add: true}) {
                                debug('add');
                        
                                if (_.get(frame,'options.source')) {
                                    const html = frame.data.posts[0].html;
                        Severity: Major
                        Found in ghost/core/core/server/api/endpoints/utils/serializers/input/posts.js - About 2 hrs to fix

                          Function exports has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          module.exports = (event, model) => {
                              const _ = require('lodash');
                              const {sequence} = require('@tryghost/promise');
                              const api = require('../../api').endpoints;
                              const apiFramework = require('@tryghost/api-framework');
                          Severity: Major
                          Found in ghost/core/core/server/services/webhooks/serialize.js - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language