Showing 1,820 of 4,015 total issues
Function useSearchService
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
const useSearchService = () => {
const [filter, setFilter] = useState('');
const [noResult, setNoResult] = useState(false);
const checkVisible = (keywords: string[]) => {
- 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 ThemeActions
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
const ThemeActions: React.FC<ThemeActionProps> = ({
theme
}) => {
const {mutateAsync: activateTheme} = useActivateTheme();
const {mutateAsync: deleteTheme} = useDeleteTheme();
- 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 MultiSelect
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
const MultiSelect: React.FC<MultiSelectProps> = ({
title = '',
clearBg = false,
error = false,
placeholder,
- 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 Avatar
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
export const Avatar: React.FC<AvatarProps> = ({comment}) => {
const {member, avatarSaturation, t} = useAppContext();
const dimensionClasses = getDimensionClasses();
const memberName = member?.name ?? comment?.member?.name;
- 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 getSubscriptionEvents
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getSubscriptionEvents(options = {}, filter) {
options = {
...options,
withRelated: [
'member',
Function start
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
start(rootApp) {
debug('Starting...');
this.rootApp = rootApp;
const {host, port, testmode, shutdownTimeout} = this.serverConfig;
Function init
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
async init() {
const debug = require('@tryghost/debug')('mediaInliner');
const MediaInliner = require('@tryghost/external-media-inliner');
const models = require('../../models');
const jobsService = require('../jobs');
Function beforeSend
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
const beforeSend = function (event, hint) {
try {
const exception = hint.originalException;
const code = exception?.code ?? null;
const context = exception?.context ?? null;
Function has
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function has(options) {
options = options || {};
options.hash = options.hash || {};
options.data = options.data || {};
Function AccountWelcome
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
const AccountWelcome = () => {
const {member, site, t} = useContext(AppContext);
const {is_stripe_configured: isStripeConfigured} = site;
if (!isStripeConfigured || hasOnlyFreePlan({site})) {
Function generatePassword
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function generatePassword(length, memorable, pattern, prefix) {
var char = '', n, i, validChars = [];
if (length === null || typeof (length) === 'undefined') {
length = 10;
}
Function generate
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
generate() {
// We need to add all properties here already otherwise CSV imports won't know all the columns
let attribution = {
attribution_id: null,
attribution_type: null,
Function error
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
error(error, transition) {
// unauthorized errors are already handled in the ajax service
if (isUnauthorizedError(error)) {
return false;
}
Function mockWebhooks
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function mockWebhooks(server) {
server.get('/webhooks/', paginatedResponse('webhooks'));
server.post('/webhooks/', function ({webhooks}) {
let attrs = this.normalizedRequestAttrs();
Function replace
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
async replace(html, replaceLink, options = {}) {
const {tokenize} = require('html5parser');
const entities = require('entities');
try {
Function createDonationCheckoutSession
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
async createDonationCheckoutSession({priceId, successUrl, cancelUrl, metadata, customer, customerEmail}) {
await this._rateLimitBucket.throttle();
/**
* @type {Stripe.Checkout.SessionCreateParams}
Function notifyPaidSubscriptionStarted
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
async notifyPaidSubscriptionStarted({member, subscription, offer, tier, attribution}, options = {}) {
const users = await this.models.User.getEmailAlertUsers('paid-started', options);
for (const user of users) {
const to = user.email;
Function objType
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
objTypeHandlers[objType] = function (modelOrId, unsafeAttrs) {
let modelId;
unsafeAttrs = unsafeAttrs || {};
// If it's an internal request, resolve immediately
Function getTotalMembersOnDatesInRange
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getTotalMembersOnDatesInRange({days, totalMembers, siteTimezone}) {
const startOfRange = moment.tz(siteTimezone).subtract(days - 1, 'days').startOf('day').utc().format(dateFormat);
const tzOffsetMins = moment.tz(siteTimezone).utcOffset();
let result;
Function init
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
async init(ghostServer) {
_enable = async () => {
if (_isClosing) {
logging.info('Waiting for previous Lexical multiplayer websockets service to close');
await _closePromise;