TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function AccountActions has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AccountActions = () => {
    const {member, onAction, site, t} = useContext(AppContext);
    const {name, email} = member;

    const openEditProfile = () => {

    Function getInputFields has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        getInputFields({state, fieldNames}) {
            const {portal_name: portalName} = this.context.site;
            const {member, t} = this.context;
            const errors = state.errors || {};
            const fields = [
    Severity: Minor
    Found in apps/portal/src/components/pages/OfferPage.js - About 1 hr to fix

      Function getAllActivities has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async getAllActivities(
              includeOwn: boolean = false,
              includeReplies: boolean = false,
              filter: {type?: string[]} | null = null
          ): Promise<Activity[]> {
      Severity: Minor
      Found in apps/admin-x-activitypub/src/api/activitypub.ts - About 1 hr to fix

        Function generate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            generate() {
                const title = faker.lorem.sentence();
                const content = faker.lorem.paragraphs(faker.datatype.number({
                    min: 3,
                    max: 10
        Severity: Minor
        Found in ghost/data-generator/lib/importers/PostsImporter.js - About 1 hr 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 finalise has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            async finalise() {
                const emailRecipients = await this.transaction.select('id', 'member_id', 'opened_at').from('email_recipients');
        
                const memberData = {};
                for (const emailRecipient of emailRecipients) {
        Severity: Minor
        Found in ghost/data-generator/lib/importers/MembersImporter.js - About 1 hr 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 modify has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            modify(element, positional, named) {
                if (!this.didSetup) {
                    this.elem = element;
                    this.addStartEventListeners();
        
        
        Severity: Minor
        Found in ghost/admin/app/modifiers/movable.js - About 1 hr 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 _showAPIError has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            _showAPIError(resp, options) {
                options = options || {};
                options.type = options.type || 'error';
        
                // if possible use the title to get a unique key
        Severity: Minor
        Found in ghost/admin/app/services/notifications.js - About 1 hr 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 dragStart has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            @action
            dragStart(e) {
                if (e.type === 'touchstart' || e.button === 0) {
                    if (e.type === 'touchstart') {
                        this.initialX = e.touches[0].clientX - this.xOffset;
        Severity: Minor
        Found in ghost/admin/app/modifiers/movable.js - About 1 hr 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 handleKeydown has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            @action
            handleKeydown(e) {
                if (this.args.onKeydown && this.args.onKeydown(e) === false) {
                    e.stopPropagation();
                    return false;
        Severity: Minor
        Found in ghost/admin/app/components/gh-token-input/trigger.js - About 1 hr 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 _uploadFile has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            _uploadFile: task(function* (tracker, file, index) {
                let ajax = this.ajax;
                let formData = this._getFormData(file);
                let url = `${ghostPaths().apiRoot}${this.uploadUrl}`;
                let metadata = null;
        Severity: Minor
        Found in ghost/admin/app/components/gh-uploader.js - About 1 hr 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 updatePortalPlansSetting has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            async updatePortalPlansSetting(plans, options) {
                if (!options) {
                    return this.models.Product.transaction((transacting) => {
                        return this.updatePortalPlansSetting(plans, {transacting});
                    });
        Severity: Minor
        Found in ghost/stripe/lib/StripeMigrations.js - About 1 hr 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 config has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            config(env) {
                // only set this.env on the first call otherwise when `postBuild()` is
                // called this.env will always be 'test' due to multiple `config()` calls
                if (!this.env) {
                    this.env = env;
        Severity: Minor
        Found in ghost/admin/lib/asset-delivery/index.js - About 1 hr 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 bulkEdit has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            async bulkEdit(data, options) {
                const {all, filter, search} = options;
        
                if (!['unsubscribe', 'addLabel', 'removeLabel'].includes(data.action)) {
                    throw new errors.IncorrectUsageError({
        Severity: Minor
        Found in ghost/members-api/lib/repositories/MemberRepository.js - About 1 hr 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 _setAttributionMetadata has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            async _setAttributionMetadata(metadata) {
                // Don't allow to set the source manually
                delete metadata.attribution_id;
                delete metadata.attribution_url;
                delete metadata.attribution_type;
        Severity: Minor
        Found in ghost/members-api/lib/controllers/RouterController.js - About 1 hr 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 permissible has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            permissible: async function permissible(postModel, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
                let isContributor;
                let isOwner;
                let isAdmin;
                let isEditor;
        Severity: Minor
        Found in ghost/core/core/server/models/post.js - About 1 hr 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 handleMismatch has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            async handleMismatch({acceptVersion, contentVersion, apiKeyValue, apiKeyType, requestURL, userAgent = ''}) {
                if (!await this.versionNotificationsDataService.fetchNotification(acceptVersion)) {
                    const integration = await this.versionNotificationsDataService.getIntegration(apiKeyValue, apiKeyType);
        
                    // We couldn't find the integration

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

        module.exports = function (Bookshelf) {
            Bookshelf.Model = Bookshelf.Model.extend({
                getActor(options = {context: {}}) {
                    if (options.context && options.context.integration) {
                        return {
        Severity: Minor
        Found in ghost/core/core/server/models/base/plugins/user-type.js - About 1 hr 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 forPost has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        const forPost = (attrs, frame) => {
            // CASE: Access always defaults to true, unless members is enabled and the member does not have access
            if (!Object.prototype.hasOwnProperty.call(frame.options, 'columns') || (frame.options.columns.includes('access'))) {
                attrs.access = true;
            }

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

        const findOrCreateLabels = async (labels, options) => {
            const existingLabels = [];
            const createdLabels = [];
        
            for (const label of labels) {
        Severity: Minor
        Found in ghost/core/core/server/services/members/importer/labels.js - About 1 hr 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 parseRedirectsFile has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        const parseRedirectsFile = (content, ext) => {
            if (ext === '.json') {
                let redirects;
        
                try {

        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

        Severity
        Category
        Status
        Source
        Language