TryGhost/Ghost

View on GitHub
ghost/admin/mirage/config/members.js

Summary

Maintainability
D
2 days
Test Coverage

Function mockMembers has 216 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function mockMembers(server) {
    server.post('/members/', withPermissionsCheck(ALLOWED_ROLES, function ({members}) {
        const attrs = this.normalizedRequestAttrs();
        return members.create(attrs);
    }));
Severity: Major
Found in ghost/admin/mirage/config/members.js - About 1 day to fix

    File members.js has 277 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import faker from 'faker';
    import moment from 'moment-timezone';
    import nql from '@tryghost/nql';
    import {Response} from 'miragejs';
    import {
    Severity: Minor
    Found in ghost/admin/mirage/config/members.js - About 2 hrs to fix

      Function mockMembersStats has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function mockMembersStats(server) {
          server.get('/members/stats/count', withPermissionsCheck(ALLOWED_ROLES, function (db, {queryParams}) {
              let {days} = queryParams;
      
              let firstSubscriberDays = faker.datatype.number({min: 30, max: 600});
      Severity: Minor
      Found in ghost/admin/mirage/config/members.js - About 1 hr to fix

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

            server.get('/members/:id/', withPermissionsCheck(ALLOWED_ROLES, function ({members}, {params}) {
                let {id} = params;
                let member = members.find(id);
        
                return member || new Response(404, {}, {
        Severity: Major
        Found in ghost/admin/mirage/config/members.js and 1 other location - About 3 hrs to fix
        ghost/admin/mirage/config/tiers.js on lines 24..34

        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 96.

        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

                                price: {
                                    id: '',
                                    price_id: '',
                                    nickname: 'Complimentary',
                                    amount: 0,
        Severity: Major
        Found in ghost/admin/mirage/config/members.js and 1 other location - About 1 hr to fix
        ghost/members-api/lib/services/MemberBREADService.js on lines 103..115

        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 61.

        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

            server.post('/members/', withPermissionsCheck(ALLOWED_ROLES, function ({members}) {
                const attrs = this.normalizedRequestAttrs();
                return members.create(attrs);
            }));
        Severity: Minor
        Found in ghost/admin/mirage/config/members.js and 1 other location - About 55 mins to fix
        ghost/admin/mirage/config/tiers.js on lines 16..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 53.

        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

                            Object.keys(member.attrs).forEach((key) => {
                                serializedMember[underscore(key)] = member.attrs[key];
                            });
        Severity: Major
        Found in ghost/admin/mirage/config/members.js and 2 other locations - About 50 mins to fix
        ghost/admin/mirage/config/members.js on lines 122..124
        ghost/admin/mirage/config/members.js on lines 322..324

        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 51.

        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

                                    Object.keys(associatedModel.attrs).forEach((key) => {
                                        serializedAssociation[underscore(key)] = associatedModel.attrs[key];
                                    });
        Severity: Major
        Found in ghost/admin/mirage/config/members.js and 2 other locations - About 50 mins to fix
        ghost/admin/mirage/config/members.js on lines 113..115
        ghost/admin/mirage/config/members.js on lines 322..324

        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 51.

        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

                            Object.keys(event.attrs).forEach((key) => {
                                serializedEvent[underscore(key)] = event.attrs[key];
                            });
        Severity: Major
        Found in ghost/admin/mirage/config/members.js and 2 other locations - About 50 mins to fix
        ghost/admin/mirage/config/members.js on lines 113..115
        ghost/admin/mirage/config/members.js on lines 122..124

        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 51.

        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

        There are no issues that match your filters.

        Category
        Status