Showing 1,820 of 4,015 total issues
Function initServices
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function initServices() {
debug('Begin: initServices');
debug('Begin: Services');
const stripe = require('./server/services/stripe');
Function fetchOembedDataFromUrl
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
async fetchOembedDataFromUrl(url, type, options = {}) {
try {
const urlObject = new URL(url);
// YouTube has started not returning oembed <link>tags for some live URLs
Function BuiltInIntegrations
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
const BuiltInIntegrations: React.FC = () => {
const {config} = useGlobalData();
const {updateRoute} = useRouting();
const openModal = (modal: string) => {
Function SlackModal
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
const SlackModal = NiceModal.create(() => {
const {updateRoute} = useRouting();
const {localSettings, updateSetting, handleSave, validate, errors, clearError, okProps} = useSettingGroup({
onValidate: () => {
Function create
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
static async create(data, uniqueChecker) {
let isNew = false;
let id;
if (data.id instanceof ObjectID) {
- 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 beforeSend
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
const beforeSend = function (event, hint) {
try {
const exception = hint.originalException;
const code = exception?.code ?? null;
const context = exception?.context ?? 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 NotificationText
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
const NotificationText = ({type, status, context}) => {
const t = context.t;
const signinPortalLink = getPortalLink({page: 'signin', siteUrl: context.site.url});
const singupPortalLink = getPortalLink({page: 'signup', siteUrl: context.site.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 setupFirstPromoter
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
setupFirstPromoter({site, member}) {
if (hasMode(['test'])) {
return null;
}
const firstPromoterId = getFirstpromoterId({site});
- 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 TierDetailPreview
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
const TierDetailPreview: React.FC<TierDetailPreviewProps> = ({tier, isFreeTier}) => {
const [showingYearly, setShowingYearly] = useState(false);
const name = tier?.name || '';
const description = tier?.description || '';
- 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 SignupOptions
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
}> = ({localSettings, updateSetting, localTiers, updateTier, errors, setError}) => {
const {config} = useGlobalData();
const [membersSignupAccess, portalName, portalSignupTermsHtml, portalSignupCheckboxRequired, portalPlansJson, portalDefaultPlan] = getSettingValues(
localSettings, ['members_signup_access', 'portal_name', 'portal_signup_terms_html', 'portal_signup_checkbox_required', 'portal_plans', 'portal_default_plan']
);
- 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 useForm
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
const useForm = <State>({initialState, savingDelay, savedDelay = 2000, onSave, onSaveError, onSavedStateReset: onSaveCompleted, onValidate}: {
initialState: State;
savingDelay?: number;
savedDelay?: number;
onSave: (state: State) => void | Promise<void>;
- 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 21 (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
File SettingsBREADService.js
has 287 lines of code (exceeds 250 allowed). Consider refactoring. Open
const _ = require('lodash');
const tpl = require('@tryghost/tpl');
const {NotFoundError, NoPermissionError, BadRequestError, IncorrectUsageError, ValidationError} = require('@tryghost/errors');
const {obfuscatedSetting, isSecretSetting, hideValueIfSecret} = require('./settings-utils');
const logging = require('@tryghost/logging');
Function pipeline
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
const pipeline = (apiController, apiUtils, apiType) => {
if (controllerMap.has(apiController)) {
return controllerMap.get(apiController);
}
Function edit
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
edit: function edit(data, unfilteredOptions) {
const options = this.filterOptions(unfilteredOptions, 'edit');
const self = this;
const ops = [];
Function exports
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = createIrreversibleMigration(async (knex) => {
logging.info('Populating slack_url and slack_username setting values');
const slackURLSetting = await knex('settings')
.select('value')
Function RecommendationsPage
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
const RecommendationsPage = () => {
const {api, site, pageData, t, onAction} = useContext(AppContext);
const {title, icon} = site;
const {recommendations_enabled: recommendationsEnabled = false} = site;
const [recommendations, setRecommendations] = useState(null);
Function filterRelations
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
filterRelations() {
return {
labels: {
tableName: 'labels',
type: 'manyToMany',
Function BetaFeatures
has 71 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);
Function useFetchApi
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const useFetchApi = () => {
const {ghostVersion, sentryDSN} = useFramework();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return async <ResponseData = any>(endpoint: string | URL, {headers = {}, retry, ...options}: RequestOptions = {}): Promise<ResponseData> => {