TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function ZapierModal has 103 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ZapierModal = NiceModal.create(() => {
    const modal = NiceModal.useModal();
    const {updateRoute} = useRouting();
    const {zapierTemplates} = useSettingsApp();
    const {data: {integrations} = {integrations: []}} = useBrowseIntegrations();

    Function AnnouncementBarModal has 103 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const AnnouncementBarModal: React.FC = () => {
        const {siteData} = useGlobalData();
        const {localSettings, updateSetting, handleSave, okProps} = useSettingGroup({savingDelay: 500});
        const [announcementContent] = getSettingValues<string>(localSettings, ['announcement_content']);
        const [accentColor] = getSettingValues<string>(localSettings, ['accent_color']);

      Function Content has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      const Content = () => {
          const labs = useLabs();
          const {t} = useAppContext();
      
          const {pagination, member, comments, commentCount, commentsEnabled, title, showCount, secundaryFormCount} = useAppContext();
      Severity: Minor
      Found in apps/comments-ui/src/components/content/Content.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 PreviewModalContent has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      export const PreviewModalContent: React.FC<PreviewModalProps> = ({
          testId,
          title,
          titleHeadingLevel = 4,
          size = 'full',
      Severity: Minor
      Found in apps/admin-x-design-system/src/global/modal/PreviewModal.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 chartOptions has 102 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          get chartOptions() {
              const barColor = this.feature.nightShift ? 'rgba(200, 204, 217, 0.25)' : 'rgba(200, 204, 217, 0.65)';
      
              return {
                  responsive: true,
      Severity: Major
      Found in ghost/admin/app/components/dashboard/charts/paid-breakdown.js - About 4 hrs to fix

        Function init has 102 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            init() {
                if (this.service) {
                    return;
                }
        
        
        Severity: Major
        Found in ghost/core/core/server/services/email-service/EmailServiceWrapper.js - About 4 hrs to fix

          App has 32 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 4 hrs to fix

            ActivityPubAPI has 32 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export class ActivityPubAPI {
                constructor(
                    private readonly apiUrl: URL,
                    private readonly authApiUrl: URL,
                    private readonly handle: string,
            Severity: Minor
            Found in apps/admin-x-activitypub/src/api/activitypub.ts - About 4 hrs to fix

              File dashboard-mocks.js has 332 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import Service from '@ember/service';
              import {tracked} from '@glimmer/tracking';
              
              /**
               * @typedef {import('./dashboard-stats').MemberCountStat} MemberCountStat
              Severity: Minor
              Found in ghost/admin/app/services/dashboard-mocks.js - About 4 hrs to fix

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

                module.exports = function (Bookshelf) {
                    Bookshelf.Model = Bookshelf.Model.extend({
                        // Ghost option handling - get permitted attributes from server/data/schema.js, where the DB schema is defined
                        permittedAttributes: function permittedAttributes() {
                            return _.keys(schema.tables[this.tableName])
                Severity: Major
                Found in ghost/core/core/server/models/base/plugins/sanitize.js - About 3 hrs to fix

                  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 AccountEmailPage has 98 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export default function AccountEmailPage() {
                        const {member, onAction, site, t, pageData} = useContext(AppContext);
                        let newsletterUuid;
                        let action;
                        if (pageData) {
                    Severity: Major
                    Found in apps/portal/src/components/pages/AccountEmailPage.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();
                      
                      

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

                        module.exports = function body_class(options) { // eslint-disable-line camelcase
                            let classes = [];
                            const context = options.data.root.context || [];
                            const obj = this.post || this.page;
                            const tags = obj && obj.tags ? obj.tags : [];
                        Severity: Minor
                        Found in ghost/core/core/frontend/helpers/body_class.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 sendMagicLink has 97 lines of code (exceeds 25 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: Major
                        Found in ghost/members-api/lib/controllers/RouterController.js - About 3 hrs to fix

                          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[]>([]);
                              Severity
                              Category
                              Status
                              Source
                              Language