Showing 1,820 of 4,015 total issues
Function content
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function content(options = {}) {
let self = this;
let args = arguments;
const hash = options.hash || {};
- Read upRead up
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 pickTemplate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
_private.pickTemplate = function pickTemplate(templateList, fallback) {
let template;
if (!_.isArray(templateList)) {
templateList = [templateList];
- Read upRead up
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
Avoid deeply nested control flow statements. Open
} else if (_.includes(context, 'page') && data.post) {
// Page description dependent on legacy object formatting (https://github.com/TryGhost/Ghost/issues/10042)
if (options.property) {
description = data.post[`${options.property}_description`]
|| data.post.custom_excerpt
Function getAnnouncementBarHelper
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getAnnouncementBarHelper(data) {
const preview = data?.site?._preview;
const isFilled = settingsCache.get('announcement_content') && settingsCache.get('announcement_visibility').length;
if (!isFilled && !preview) {
- Read upRead up
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 match
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function match(...attrs) {
// options = options || {};
// options.hash = options.hash || {};
// options.data = options.data || {};
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if (options.property) {
description = data.post[`${options.property}_description`]
|| data.post.custom_excerpt
|| data.post.meta_description
|| generateExcerpt(data.post.excerpt || '', {words: 50})
Function getCoverImage
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getCoverImage(data) {
const context = data.context ? data.context : null;
const contextObject = getContextObject(data, context);
if (_.includes(context, 'home') || _.includes(context, 'author')) {
- Read upRead up
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 getSchema
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function getSchema(metaData, data) {
if (!config.isPrivacyDisabled('useStructuredData')) {
const context = data.context ? data.context : null;
if (_.includes(context, 'post') || _.includes(context, 'page') || _.includes(context, 'amp')) {
return getPostSchema(metaData, data);
- Read upRead up
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 _doGet
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
_doGet(key, options) {
// NOTE: "!this.settingsCache" is for when setting's cache is used
// before it had a chance to initialize. Should be fixed when
// it is decoupled from the model layer
if (!this.settingsCache) {
- Read upRead up
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 memberCountRounding
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const memberCountRounding = (memberCount) => {
if (memberCount <= 50) {
return memberCount;
}
- Read upRead up
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 handle
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async handle(argv = {}) {
const _ = require('lodash');
// knex has to be loaded _after_ the call to setup()
// the db connection requires nconf which passes argv to yargs,
// which intercepts --help and stops execution
- Read upRead up
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 fromApiResponse
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static async fromApiResponse(res) {
// Bad request + Too many requests
if (res.status === 400 || res.status === 429) {
try {
const json = await res.json();
- Read upRead up
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 getQueryPrice
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function getQueryPrice({site = {}, priceId}) {
const prices = getAvailablePrices({site});
if (priceId === 'free') {
return !prices || prices.length === 0 || prices.find(p => p.type === 'free');
} else if (prices && prices.length > 0 && priceId === 'monthly') {
- Read upRead up
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 handler
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function handler(siteApp) {
const verifyResourceType = function verifyResourceType(req, res, next) {
const resourceWithoutPage = req.params.resource.replace(/-\d+$/, '');
if (!Object.prototype.hasOwnProperty.call(manager, resourceWithoutPage)) {
return res.sendStatus(404);
- Read upRead up
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 fetchBookmarkData
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async fetchBookmarkData(url, html) {
const gotOpts = {
headers: {
'User-Agent': USER_AGENT
}
- Read upRead up
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 invertColor
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function invertColor(hex = '', bw = true) {
if (!hex || !hex.match(/#[0-9A-Fa-f]{6}$/)) {
// Return white in case not a valid hex
return '#000000';
}
- Read upRead up
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 onPlanCheckout
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
onPlanCheckout(e, priceId) {
const {onAction, member} = this.context;
let {confirmationPlan, selectedPlan} = this.state;
if (priceId) {
selectedPlan = priceId;
- Read upRead up
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 ProductsSection
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function ProductsSection({onPlanSelect, products, type = null, handleChooseSignup, errors}) {
const {site, member, t} = useContext(AppContext);
const {portal_plans: portalPlans, portal_default_plan: portalDefaultPlan} = site;
const defaultProductId = products.length > 0 ? products[0].id : 'free';
- Read upRead up
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 equals
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function equals(a: unknown, b: unknown) {
if (a === null || b === null) {
return a === b;
}
if (a === undefined || b === undefined) {
- Read upRead up
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 addPost
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
addPost(post: CollectionPost, index: number = -0) {
if (this.slug === 'latest') {
return false;
}
if (this.type === 'automatic') {
- Read upRead up
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"