Calculating total size of player data I am writing a function to calculate the total size of a "player appearance".

There are various "item slots" the player has, and if they are empty then 1 byte will be sent, otherwise there will be 2.

const getAppearanceBlockSize = (appearance: PlayerAppearance) =&gt; {
    const headObscured = isCoveringHead(appearance.outfit.head);

    return (
        40
        + (appearance.outfit.head ? 2 : 1)
        + (appearance.outfit.cape ? 2 : 1)
        + (appearance.outfit.amulet ? 2 : 1)
        + (appearance.outfit.weapon ? 2 : 1)
        + (appearance.outfit.shield ? 2 : 1)
        + (appearance.outfit.head ? 2 : 1)
        + (headObscured ? 2 : 4)
    );
};


The code seems fairly clear to me, but Code Climate has given it a high "cognitive complexity" score - indicating that the code is complex and should be broken up.

I can't think of any ways to break the code up, however, that wouldn't result in it being more complex than it currently is.
I don't know anything about CodeClimate or how it determines complexity, but this is the likely culprit right here:

return (
    40
    + (appearance.outfit.head ? 2 : 1)
    + (appearance.outfit.cape ? 2 : 1)
    + (appearance.outfit.amulet ? 2 : 1)
    + (appearance.outfit.weapon ? 2 : 1)
    + (appearance.outfit.shield ? 2 : 1)
    + (appearance.outfit.head ? 2 : 1)
    + (headObscured ? 2 : 4)
);


This is pretty hard to read and understand at a glance, and all of the ternary operators certainly don't help. Without knowing more about your object it is hard to review, but to me it would make more sense to have a method like this on your outfit object

function getSlotSize(slot) {
    let size = 0;
    if (this.slots.includes(slot)) {
        size = slotIsEmpty(slot) ? 2 : 1;
        if (slot === "head") {
            size += 2 * isCoveringHead(this.head);
        }
    }

    return size;
}

function slotIsEmpty(slot) {
    return this.[slot] === null || this.[slot] === undefined;
}


Now you've separated out your logic for determining the size of everything instead of having to jam it into one function.

An even better approach may be to OOP this, and create objects representing a slot (or a specific kind of slot) and then each one should have a getSize method. Without knowing more about your code it is hard to say whether or not that would be overkill.