TryGhost/Ghost

View on GitHub

Showing 2,188 of 3,985 total issues

Similar blocks of code found in 12 locations. Consider refactoring.
Open

    codeinjectionHead(model) {
        if (!validator.isLength(model.codeinjectionHead || '', 0, 65535)) {
            model.errors.add('codeinjectionHead', 'Header code cannot be longer than 65535 characters.');
            this.invalidate();
        }
Severity: Major
Found in ghost/admin/app/validators/post.js and 11 other locations - About 1 hr to fix
ghost/admin/app/validators/member.js on lines 8..13
ghost/admin/app/validators/offer.js on lines 57..62
ghost/admin/app/validators/post.js on lines 87..92
ghost/admin/app/validators/post.js on lines 101..106
ghost/admin/app/validators/post.js on lines 108..113
ghost/admin/app/validators/post.js on lines 115..120
ghost/admin/app/validators/post.js on lines 122..127
ghost/admin/app/validators/post.js on lines 129..134
ghost/admin/app/validators/post.js on lines 136..141
ghost/admin/app/validators/post.js on lines 143..148
ghost/admin/app/validators/post.js on lines 207..212

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 12 locations. Consider refactoring.
Open

    name(model) {
        if (!validator.isLength(model.name || '', 0, 191)) {
            model.errors.add('name', 'Name cannot be longer than 191 characters.');
            this.invalidate();
        }
Severity: Major
Found in ghost/admin/app/validators/member.js and 11 other locations - About 1 hr to fix
ghost/admin/app/validators/offer.js on lines 57..62
ghost/admin/app/validators/post.js on lines 87..92
ghost/admin/app/validators/post.js on lines 94..99
ghost/admin/app/validators/post.js on lines 101..106
ghost/admin/app/validators/post.js on lines 108..113
ghost/admin/app/validators/post.js on lines 115..120
ghost/admin/app/validators/post.js on lines 122..127
ghost/admin/app/validators/post.js on lines 129..134
ghost/admin/app/validators/post.js on lines 136..141
ghost/admin/app/validators/post.js on lines 143..148
ghost/admin/app/validators/post.js on lines 207..212

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 12 locations. Consider refactoring.
Open

    metaTitle(model) {
        if (!validator.isLength(model.metaTitle || '', 0, 300)) {
            model.errors.add('metaTitle', 'Meta Title cannot be longer than 300 characters.');
            this.invalidate();
        }
Severity: Major
Found in ghost/admin/app/validators/post.js and 11 other locations - About 1 hr to fix
ghost/admin/app/validators/member.js on lines 8..13
ghost/admin/app/validators/offer.js on lines 57..62
ghost/admin/app/validators/post.js on lines 87..92
ghost/admin/app/validators/post.js on lines 94..99
ghost/admin/app/validators/post.js on lines 108..113
ghost/admin/app/validators/post.js on lines 115..120
ghost/admin/app/validators/post.js on lines 122..127
ghost/admin/app/validators/post.js on lines 129..134
ghost/admin/app/validators/post.js on lines 136..141
ghost/admin/app/validators/post.js on lines 143..148
ghost/admin/app/validators/post.js on lines 207..212

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 12 locations. Consider refactoring.
Open

    metaDescription(model) {
        if (!validator.isLength(model.metaDescription || '', 0, 500)) {
            model.errors.add('metaDescription', 'Meta Description cannot be longer than 500 characters.');
            this.invalidate();
        }
Severity: Major
Found in ghost/admin/app/validators/post.js and 11 other locations - About 1 hr to fix
ghost/admin/app/validators/member.js on lines 8..13
ghost/admin/app/validators/offer.js on lines 57..62
ghost/admin/app/validators/post.js on lines 87..92
ghost/admin/app/validators/post.js on lines 94..99
ghost/admin/app/validators/post.js on lines 101..106
ghost/admin/app/validators/post.js on lines 115..120
ghost/admin/app/validators/post.js on lines 122..127
ghost/admin/app/validators/post.js on lines 129..134
ghost/admin/app/validators/post.js on lines 136..141
ghost/admin/app/validators/post.js on lines 143..148
ghost/admin/app/validators/post.js on lines 207..212

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 12 locations. Consider refactoring.
Open

    emailSubject(model) {
        if (!validator.isLength(model.emailSubject || '', 0, 300)) {
            model.errors.add('emailSubject', 'Email Subject cannot be longer than 300 characters.');
            this.invalidate();
        }
Severity: Major
Found in ghost/admin/app/validators/post.js and 11 other locations - About 1 hr to fix
ghost/admin/app/validators/member.js on lines 8..13
ghost/admin/app/validators/offer.js on lines 57..62
ghost/admin/app/validators/post.js on lines 87..92
ghost/admin/app/validators/post.js on lines 94..99
ghost/admin/app/validators/post.js on lines 101..106
ghost/admin/app/validators/post.js on lines 108..113
ghost/admin/app/validators/post.js on lines 115..120
ghost/admin/app/validators/post.js on lines 122..127
ghost/admin/app/validators/post.js on lines 129..134
ghost/admin/app/validators/post.js on lines 136..141
ghost/admin/app/validators/post.js on lines 207..212

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 12 locations. Consider refactoring.
Open

    ogDescription(model) {
        if (!validator.isLength(model.ogDescription || '', 0, 500)) {
            model.errors.add('ogDescription', 'Facebook Description cannot be longer than 500 characters.');
            this.invalidate();
        }
Severity: Major
Found in ghost/admin/app/validators/post.js and 11 other locations - About 1 hr to fix
ghost/admin/app/validators/member.js on lines 8..13
ghost/admin/app/validators/offer.js on lines 57..62
ghost/admin/app/validators/post.js on lines 87..92
ghost/admin/app/validators/post.js on lines 94..99
ghost/admin/app/validators/post.js on lines 101..106
ghost/admin/app/validators/post.js on lines 108..113
ghost/admin/app/validators/post.js on lines 115..120
ghost/admin/app/validators/post.js on lines 129..134
ghost/admin/app/validators/post.js on lines 136..141
ghost/admin/app/validators/post.js on lines 143..148
ghost/admin/app/validators/post.js on lines 207..212

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 12 locations. Consider refactoring.
Open

    twitterDescription(model) {
        if (!validator.isLength(model.twitterDescription || '', 0, 500)) {
            model.errors.add('twitterDescription', 'Twitter Description cannot be longer than 500 characters.');
            this.invalidate();
        }
Severity: Major
Found in ghost/admin/app/validators/post.js and 11 other locations - About 1 hr to fix
ghost/admin/app/validators/member.js on lines 8..13
ghost/admin/app/validators/offer.js on lines 57..62
ghost/admin/app/validators/post.js on lines 87..92
ghost/admin/app/validators/post.js on lines 94..99
ghost/admin/app/validators/post.js on lines 101..106
ghost/admin/app/validators/post.js on lines 108..113
ghost/admin/app/validators/post.js on lines 115..120
ghost/admin/app/validators/post.js on lines 122..127
ghost/admin/app/validators/post.js on lines 129..134
ghost/admin/app/validators/post.js on lines 143..148
ghost/admin/app/validators/post.js on lines 207..212

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 12 locations. Consider refactoring.
Open

    featureImageAlt(model) {
        if (!validator.isLength(model.featureImageAlt || '', 0, 125)) {
            model.errors.add('featureImageAlt', 'Feature image alt text cannot be longer than 125 characters.');
            this.invalidate();
        }
Severity: Major
Found in ghost/admin/app/validators/post.js and 11 other locations - About 1 hr to fix
ghost/admin/app/validators/member.js on lines 8..13
ghost/admin/app/validators/offer.js on lines 57..62
ghost/admin/app/validators/post.js on lines 87..92
ghost/admin/app/validators/post.js on lines 94..99
ghost/admin/app/validators/post.js on lines 101..106
ghost/admin/app/validators/post.js on lines 108..113
ghost/admin/app/validators/post.js on lines 115..120
ghost/admin/app/validators/post.js on lines 122..127
ghost/admin/app/validators/post.js on lines 129..134
ghost/admin/app/validators/post.js on lines 136..141
ghost/admin/app/validators/post.js on lines 143..148

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 12 locations. Consider refactoring.
Open

    displayDescription(model) {
        if (!validator.isLength(model.displayDescription || '', 0, 191)) {
            model.errors.add('displayDescription', 'Display description cannot be longer than 191 characters.');
            this.invalidate();
        }
Severity: Major
Found in ghost/admin/app/validators/offer.js and 11 other locations - About 1 hr to fix
ghost/admin/app/validators/member.js on lines 8..13
ghost/admin/app/validators/post.js on lines 87..92
ghost/admin/app/validators/post.js on lines 94..99
ghost/admin/app/validators/post.js on lines 101..106
ghost/admin/app/validators/post.js on lines 108..113
ghost/admin/app/validators/post.js on lines 115..120
ghost/admin/app/validators/post.js on lines 122..127
ghost/admin/app/validators/post.js on lines 129..134
ghost/admin/app/validators/post.js on lines 136..141
ghost/admin/app/validators/post.js on lines 143..148
ghost/admin/app/validators/post.js on lines 207..212

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            if (frame.user) {
                email = frame.user.get('email');
            } else {
                email = await models.User.getOwnerUser().get('email');
            }
Severity: Major
Found in ghost/core/core/server/api/endpoints/members.js and 1 other location - About 1 hr to fix
ghost/core/core/server/api/endpoints/db.js on lines 95..99

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        if (uploadResponse) {
            let resource = get(uploadResponse, this.resourceName);
            if (resource && isArray(resource) && resource[0]) {
                responseUrl = get(resource[0], 'url');
            }
Severity: Major
Found in ghost/admin/app/components/gh-image-uploader.js and 1 other location - About 1 hr to fix
ghost/admin/app/components/gh-uploader.js on lines 289..294

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            if (uploadResponse) {
                let resource = get(uploadResponse, this.resourceName);
                if (resource && isArray(resource) && resource[0]) {
                    responseUrl = get(resource[0], 'url');
                }
Severity: Major
Found in ghost/admin/app/components/gh-uploader.js and 1 other location - About 1 hr to fix
ghost/admin/app/components/gh-image-uploader.js on lines 227..232

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            if (frame.user) {
                email = frame.user.get('email');
            } else {
                email = await models.User.getOwnerUser().get('email');
            }
Severity: Major
Found in ghost/core/core/server/api/endpoints/db.js and 1 other location - About 1 hr to fix
ghost/core/core/server/api/endpoints/members.js on lines 426..430

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    get totalMembersTrend() {
        if (this.dashboardStats.memberCountsTrend) {
            return this.calculatePercentage(this.dashboardStats.memberCountsTrend.total, this.dashboardStats.memberCounts.total);
        }
        return 0;
ghost/admin/app/components/dashboard/charts/anchor-attribution.js on lines 165..170
ghost/admin/app/components/dashboard/charts/anchor-attribution.js on lines 172..177

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    constructor({urlService, urlUtils, models}) {
        this.urlService = urlService;
        this.urlUtils = urlUtils;
        this.models = models;
    }
Severity: Major
Found in ghost/member-attribution/lib/UrlTranslator.js and 2 other locations - About 1 hr to fix
ghost/core/core/server/services/members/stats/MembersStats.js on lines 11..15
ghost/email-content-generator/lib/EmailContentGenerator.js on lines 15..19

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    constructor({getSiteUrl, getSiteTitle, templatesDir}) {
        this.getSiteUrl = getSiteUrl;
        this.getSiteTitle = getSiteTitle;
        this.templatesDir = templatesDir;
    }
Severity: Major
Found in ghost/email-content-generator/lib/EmailContentGenerator.js and 2 other locations - About 1 hr to fix
ghost/core/core/server/services/members/stats/MembersStats.js on lines 11..15
ghost/member-attribution/lib/UrlTranslator.js on lines 22..26

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    get freeMembersTrend() {
        if (this.dashboardStats.memberCountsTrend) {
            return this.calculatePercentage(this.dashboardStats.memberCountsTrend.free, this.dashboardStats.memberCounts.free);
        }
        return 0;
ghost/admin/app/components/dashboard/charts/anchor-attribution.js on lines 158..163
ghost/admin/app/components/dashboard/charts/anchor-attribution.js on lines 165..170

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    get paidMembersTrend() {
        if (this.dashboardStats.memberCountsTrend) {
            return this.calculatePercentage(this.dashboardStats.memberCountsTrend.paid, this.dashboardStats.memberCounts.paid);
        }
        return 0;
ghost/admin/app/components/dashboard/charts/anchor-attribution.js on lines 158..163
ghost/admin/app/components/dashboard/charts/anchor-attribution.js on lines 172..177

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

    constructor({db, settingsCache, isSQLite}) {
        this._db = db;
        this._settingsCache = settingsCache;
        this._isSQLite = isSQLite;
    }
ghost/email-content-generator/lib/EmailContentGenerator.js on lines 15..19
ghost/member-attribution/lib/UrlTranslator.js on lines 22..26

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        if (
            !this.get('mobiledoc') &&
            (
                this.hasChanged('lexical')
                || options.force_rerender
Severity: Major
Found in ghost/core/core/server/models/post.js and 1 other location - About 1 hr to fix
ghost/core/core/server/models/post.js on lines 736..752

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 62.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language