Showing 1,820 of 4,015 total issues
Function useSortableIndexedList
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const useSortableIndexedList = <Item extends unknown>({items, setItems, blank, canAddNewItem}: {
items: Item[];
setItems: (newItems: Item[]) => void;
blank: Item
canAddNewItem: (item: Item) => boolean
- 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 AddDetailsPopup
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const AddDetailsPopup = (props: Props) => {
const inputNameRef = useRef<HTMLInputElement>(null);
const inputExpertiseRef = useRef<HTMLInputElement>(null);
const {dispatchAction, member, accentColor, t} = useAppContext();
- 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 CTABox
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const CTABox: React.FC<Props> = ({isFirst, isPaid}) => {
const {accentColor, commentCount, publication, member, t} = useAppContext();
const buttonStyle = {
backgroundColor: accentColor
- 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 Form
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const Form: React.FC<FormProps> = ({
title,
grouped = false,
gap = 'md',
margins = 'md',
- 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 useFilterableApi
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const useFilterableApi = <
Data extends {id: string} & {[k in FilterKey]: string} & {[k: string]: unknown},
ResponseKey extends string = string,
FilterKey extends string = string
>({path, filterKey, responseKey, limit = 20}: {
- 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 saveNewPasswordTask
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
saveNewPasswordTask: task(function* () {
const validation = this.isLoggedIn ? 'ownPasswordChange' : 'passwordChange';
try {
yield this.validate({property: validation});
Function mockInvites
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function mockInvites(server) {
server.get('/invites/', paginatedResponse('invites'));
server.get('/invites/:id', function (schema, request) {
let {id} = request.params;
Function handleNotification
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleNotification(message, delayed = false) {
const wordRegex = /[a-z]+/igm;
const wordMatches = (message.message.string || message.message).matchAll(wordRegex);
for (const wordMatch of wordMatches) {
Function getStatsParams
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function getStatsParams(config, props, additionalParams = {}) {
const {chartRange, audience, device, browser, location, source, pathname} = props;
const {startDate, endDate} = getDateRange(chartRange);
const params = {
Function chartData
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
get chartData() {
const stats = this.dashboardStats.filledSubscriptionCountStats;
const labels = stats.map(stat => stat.date);
const newData = stats.map(stat => stat.signups || 0);
const canceledData = stats.map(stat => -(stat.cancellations || 0));
Function apiToken
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async apiToken() {
// TODO: Getting the token can be improved
const ghostIntegrationsUrl = this.ghostPaths.url.api('integrations') + '?include=api_keys';
return this.ajax.request(ghostIntegrationsUrl).then(async (response) => {
const ssmIntegration = response.integrations.find(r => r.slug === 'self-serve-migration');
Function exchangeTokenForSession
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async exchangeTokenForSession(req, res) {
if (!req.url) {
return Promise.reject(new BadRequestError({
message: 'Expected token param containing JWT'
}));
Function customQuery
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
customQuery(qb, options) {
if (options.aggregateStatusCounts) {
if (options.limit || options.filter) {
throw new errors.IncorrectUsageError({
message: 'aggregateStatusCounts does not work when passed a filter or limit'
Function getMemberDataFromMagicLinkToken
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function getMemberDataFromMagicLinkToken(token) {
const {email, labels = [], name = '', oldEmail, newsletters, attribution, reqIp, type} = await getTokenDataFromMagicLinkToken(token);
if (!email) {
return null;
}
Function constructor
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(deps) {
/** @private */
this.OfferModel = deps.Offer;
/** @private */
this.StripeProductModel = deps.StripeProduct;
Function getNQLSubset
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
getNQLSubset(filter) {
if (!filter) {
return [undefined, undefined];
}
Function _handleMemberCreatedEvent
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
async _handleMemberCreatedEvent(event) {
const source = event.data?.source;
let sourceThreshold;
if (source === 'api') {
Function filterRelations
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
filterRelations: function filterRelations() {
return {
tags: {
tableName: 'tags',
type: 'manyToMany',
Function activityFeedMapper
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
const activityFeedMapper = (event, frame) => {
if (event.type === 'comment_event') {
return commentEventMapper(event, frame);
}
if (event.type === 'click_event') {
Function serializeTier
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function serializeTier(tier, options) {
const json = tier.toJSON(options);
const serialized = {
id: json.id,