TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function viteConfig has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default (function viteConfig() {
    return defineConfig({
        logLevel: process.env.CI ? 'info' : 'warn',
        plugins: [
            svgr(),
Severity: Major
Found in apps/signup-form/vite.config.ts - About 2 hrs to fix

    Function viteConfig has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default (function viteConfig() {
        return defineConfig({
            logLevel: process.env.CI ? 'info' : 'warn',
            plugins: [
                svgr(),
    Severity: Major
    Found in apps/admin-x-design-system/vite.config.ts - About 2 hrs to fix

      Function formatRelativeTime has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function formatRelativeTime(dateString: string, t: TranslationFunction): string {
          const date = new Date(dateString);
          const now = new Date();
      
          // Diff is in seconds
      Severity: Major
      Found in apps/comments-ui/src/utils/helpers.ts - About 2 hrs to fix

        Function getInfo has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            getInfo(event) {
                if (event.type === 'subscription_event') {
                    let mrrDelta = getNonDecimal(event.data.mrr_delta, event.data.currency);
                    if (mrrDelta === 0) {
                        return;
        Severity: Minor
        Found in ghost/admin/app/helpers/parse-member-event.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 draw has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            draw: function () {
                var ctx = this._chart.ctx;
                var vm = this._view;
                var left, right, top, bottom, borderSkipped, radius;
        
        
        Severity: Minor
        Found in ghost/admin/app/components/dashboard/charts/paid-breakdown.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 _detectDataTypes has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            _detectDataTypes(data) {
                const supportedTypes = [
                    'email',
                    'name',
                    'note',
        Severity: Minor
        Found in ghost/admin/app/services/member-import-validator.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 setupWebhook has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            async setupWebhook(id, secret, opts = {}) {
                if (!id || !secret || opts.forceCreate) {
                    if (id && !opts.skipDelete) {
                        try {
                            await this.api.deleteWebhookEndpoint(id);
        Severity: Minor
        Found in ghost/stripe/lib/WebhookManager.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 forceStripeSubscriptionToProduct has a Cognitive Complexity of 16 (exceeds 5 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: Minor
        Found in ghost/members-importer/lib/MembersCSVImporterStripeUtils.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 _syncRepositoryWithTheme has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            async _syncRepositoryWithTheme(name, theme) {
                const themeSettings = theme.customSettings || {};
        
                const settingsCollection = await this._repository.browse({filter: `theme:'${name}'`});
                let knownSettings = settingsCollection.toJSON();
        Severity: Minor
        Found in ghost/custom-theme-settings-service/lib/CustomThemeSettingsService.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 onSaving has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            async onSaving(model, _attr, options) {
                ghostBookshelf.Model.prototype.onSaving.apply(this, arguments);
        
                if (model.get('name')) {
                    model.set('name', model.get('name').trim());
        Severity: Minor
        Found in ghost/core/core/server/models/product.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 commentMapper has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        const commentMapper = (model, frame) => {
            const jsonModel = model.toJSON ? model.toJSON(frame.options) : model;
        
            const response = _.pick(jsonModel, commentFields);
        
        

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

        function getFromAddress(requestedFromAddress, requestedReplyToAddress) {
            if (settingsHelpers.useNewEmailAddresses()) {
                if (!requestedFromAddress) {
                    // Use the default config
                    requestedFromAddress = emailAddress.service.defaultFromEmail;
        Severity: Minor
        Found in ghost/core/core/server/services/mail/GhostMailer.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 getIconUrl has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            getIconUrl({absolute = false, fallbackToDefault = true} = {}) {
                const blogIcon = this.settingsCache.get('icon');
        
                if (blogIcon) {
                    // Resize + format icon to one of the supported file extensions
        Severity: Minor
        Found in ghost/core/core/server/lib/image/BlogIcon.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 post_class has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function post_class() { // eslint-disable-line camelcase
            let classes = ['post'];
        
            const tags = this.post && this.post.tags ? this.post.tags : this.tags || [];
            const featured = this.post && this.post.featured ? this.post.featured : this.featured || false;
        Severity: Minor
        Found in ghost/core/core/frontend/helpers/post_class.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 ScrollSectionProvider has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        }> = ({children}) => {
            const [navigatedSection, _setNavigatedSection] = useState<string | null>(null);
            const sectionElements = useRef<Record<string, HTMLDivElement>>({});
            const intersectionObserver = useRef<IntersectionObserver | null>(null);
            const [intersectingSections, setIntersectingSections] = useState<string[]>([]);
        Severity: Minor
        Found in apps/admin-x-settings/src/hooks/useScrollSection.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 DefaultRecipients has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        const DefaultRecipients: React.FC<{ keywords: string[] }> = ({keywords}) => {
            const {
                localSettings,
                isEditing,
                saveState,

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

        const FormEditor: React.FC<FormEditorProps> = ({submit, progress, setProgress, close, reduced, isOpen, editor, submitText, submitSize}) => {
            const labs = useLabs();
            const {t} = useAppContext();
            let buttonIcon = null;
            const [hasContent, setHasContent] = useState(false);
        Severity: Minor
        Found in apps/comments-ui/src/components/content/forms/Form.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 Heading has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        const Heading: React.FC<HeadingProps> = ({
            level = 1,
            children,
            styles = '',
            grey = true,
        Severity: Minor
        Found in apps/admin-x-design-system/src/global/Heading.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 getScrollToPosition has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        export const getScrollToPosition = (element: HTMLElement) => {
            let yOffset = 0;
        
            // Because we are working in an iframe, we need to resolve the position inside this iframe to the position in the top window
            // Get the window of the element, not the window (which is the top window)
        Severity: Minor
        Found in apps/comments-ui/src/utils/helpers.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 serializeMember has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function serializeMember(member, options) {
            const json = member.toJSON ? member.toJSON(options) : member;
        
            const comped = json.status === 'comped';
        
        
          Severity
          Category
          Status
          Source
          Language