Showing 1,756 of 3,886 total issues
Function get
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = async function get(resource, options) {
options = options || {};
options.hash = options.hash || {};
options.data = options.data || {};
Function foreach
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function foreach(items, options) {
if (!options) {
logging.warn(tpl(messages.iteratorNeeded));
}
Function render
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const {page, pageQuery, site, customSiteUrl} = this.context;
const products = getSiteProducts({site});
const noOfProducts = products.length;
Function up
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function up(knex) {
logging.info('Adjusting MRR based on Offer Redemptions');
const offerRedemptions = await knex
.select('or.*', 'o.discount_type', 'o.discount_amount', 'o.interval AS discount_interval', 's.mrr AS mrr', 's.id AS subscription_id', 'p.amount AS amount', 'p.interval AS interval')
.from('offer_redemptions AS or')
Function FirstpromoterModal
has 79 lines of code (exceeds 25 allowed). Consider refactoring. Open
const FirstpromoterModal = NiceModal.create(() => {
const {updateRoute} = useRouting();
const modal = NiceModal.useModal();
const {settings} = useGlobalData();
Function create
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async create(data, uniqueChecker) {
let isNew = false;
let id;
if (data.id instanceof ObjectID) {
Function validateSchema
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
function validateSchema(tableName, model, options) {
options = options || {};
const columns = _.keys(schema[tableName]);
let validationErrors = [];
Function updateSubscription
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
async updateSubscription(req, res) {
try {
const identity = req.body.identity;
const subscriptionId = req.params.id;
const cancelAtPeriodEnd = req.body.cancel_at_period_end;
- 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 all
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
all(_apiConfig, frame) {
if (frame.options.filter) {
try {
frame.options.filter = nql.parse(frame.options.filter);
} catch (err) {
- 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 fetchOembedDataFromUrl
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
async fetchOembedDataFromUrl(url, type, options = {}) {
try {
const urlObject = new URL(url);
// Trimming solves the difference of url validation between `new URL(url)`
- 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 NewsletterPreviewContent
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
}> = ({
senderName,
senderEmail,
senderReplyTo,
headerImage,
- 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 NewsletterPreview
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
const NewsletterPreview: React.FC<{newsletter: Newsletter}> = ({newsletter}) => {
const hasEmailCustomization = useFeatureFlag('emailCustomization');
const {currentUser, settings, siteData, config} = useGlobalData();
const [title, icon, commentsEnabled, supportEmailAddress, defaultEmailAddress] = getSettingValues<string>(settings, ['title', 'icon', 'comments_enabled', 'support_email_address', 'default_email_address']);
- 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 22 (exceeds 5 allowed). Consider refactoring. Open
const Form: React.FC<FormProps> = ({comment, submit, submitText, submitSize, close, editor, reduced, isOpen}) => {
const {member, dispatchAction} = useAppContext();
const isAskingDetails = usePopupOpen('addDetailsPopup');
const [progress, setProgress] = useState<Progress>('default');
const formEl = useRef(null);
- 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 getAction
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
getAction(event, hasMultipleNewsletters) {
if (event.type === 'signup_event' || (event.type === 'subscription_event' && event.data.type === 'created' && event.data.signup)) {
return 'signed up';
}
Function EmailReceivingPage
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function EmailReceivingPage() {
const {brandColor, onAction, site, lastPage, member, t} = useContext(AppContext);
const supportAddressEmail = getSupportAddress({site});
const supportAddress = `mailto:${supportAddressEmail}`;
File FeedbackPage.js
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {useContext, useEffect, useState} from 'react';
import AppContext from '../../AppContext';
import {ReactComponent as ThumbDownIcon} from '../../images/icons/thumbs-down.svg';
import {ReactComponent as ThumbUpIcon} from '../../images/icons/thumbs-up.svg';
import {ReactComponent as ThumbErrorIcon} from '../../images/icons/thumbs-error.svg';
Function RecommendationItem
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
const RecommendationItem = (recommendation) => {
const {t, onAction, member, site} = useContext(AppContext);
const {title, url, description, favicon, one_click_subscribe: oneClickSubscribe, featured_image: featuredImage} = recommendation;
const allowOneClickSubscribe = member && oneClickSubscribe;
const [subscribed, setSubscribed] = useState(false);
File OEmbedService.js
has 292 lines of code (exceeds 250 allowed). Consider refactoring. Open
const errors = require('@tryghost/errors');
const tpl = require('@tryghost/tpl');
const logging = require('@tryghost/logging');
const cheerio = require('cheerio');
const _ = require('lodash');
Function BetaFeatures
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
const BetaFeatures: React.FC = () => {
const {mutateAsync: uploadRedirects} = useUploadRedirects();
const {mutateAsync: uploadRoutes} = useUploadRoutes();
const handleError = useHandleError();
const [redirectsUploading, setRedirectsUploading] = useState(false);
File RecommendationsPage.js
has 291 lines of code (exceeds 250 allowed). Consider refactoring. Open
import AppContext from '../../AppContext';
import {useContext, useState, useEffect, useCallback, useMemo} from 'react';
import CloseButton from '../common/CloseButton';
import {clearURLParams} from '../../utils/notifications';
import LoadingPage from './LoadingPage';