Showing 1,820 of 4,015 total issues
Function constructor
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor(mainRoute, object, RESOURCE_CONFIG, routerCreated) {
super('CollectionRouter');
this.RESOURCE_CONFIG = RESOURCE_CONFIG.QUERY.post;
Function add
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async add({uuid, key, postId, score}) {
let url = endpointFor({type: 'members', resource: 'feedback'});
if (uuid && key) { // only necessary if not logged in, and both are required if so
url = url + `?uuid=${uuid}&key=${key}`;
}
Function serveFavicon
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function serveFavicon() {
let filePath;
return function serveFaviconMiddleware(req, res, next) {
if (req.path.match(/^\/favicon\.(ico|png|jpe?g)/i)) {
Function renderFrameContainer
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderFrameContainer() {
const {member, site, customSiteUrl} = this.context;
const Styles = StylesWrapper({member});
const isMobile = window.innerWidth < 480;
Function getInputFields
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
getInputFields({state}) {
const {t} = this.context;
const errors = state.errors || {};
const fields = [
Function fetchData
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async fetchData() {
const {site: apiSiteData, member} = await this.fetchApiData();
const {site: devSiteData, ...restDevData} = this.fetchDevData();
const {site: linkSiteData, ...restLinkData} = this.fetchLinkData(apiSiteData, member);
const {site: previewSiteData, ...restPreviewData} = this.fetchPreviewData();
Function shouldGenerateRevision
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
shouldGenerateRevision(current: PostLike, revisions: Revision[], options?: { isPublished?: boolean; forceRevision?: boolean; newStatus?: string; olderStatus?: string; }): RevisionResult {
const latestRevision = revisions[revisions.length - 1];
// If there's no revisions for this post, we should always save a revision
if (revisions.length === 0) {
return {value: true, reason: 'initial_revision'};
Function onValidate
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
onValidate: () => {
const newErrors : Record<string, string> = {};
if (!formState.name && formState.name.length === 0) {
newErrors.name = 'Name is required';
Function confirmTierStatusChange
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const confirmTierStatusChange = () => {
if (tier) {
const promptTitle = tier.active ? 'Archive tier' : 'Reactivate tier';
const prompt = tier.active ? <>
<div className='mb-6'>Members will no longer be able to subscribe to <strong>{tier.name}</strong> and it will be removed from the list of available tiers in portal.</div>
Function loadOptions
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const loadOptions: LoadMultiSelectOptions = async (input, callback) => {
const [tiersData, labelsData, offersData] = await Promise.all([tiers.loadData(input), labels.loadData(input), offers.loadData(input)]);
const segmentOptionGroups: GroupBase<MultiSelectOption>[] = [
{
Function onSort
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const onSort = async (id: string, overId?: string) => {
const fromIndex = sortedActiveNewsletters.findIndex(newsletter => newsletter.id === id);
const toIndex = sortedActiveNewsletters.findIndex(newsletter => newsletter.id === overId) || 0;
const newSortOrder = arrayMove(sortedActiveNewsletters, fromIndex, toIndex);
Function onSave
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
onSave: async () => {
let validatedUrl: URL;
validatedUrl = new URL(formState.url);
// Use the hostname as fallback title
Function Pagination
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const Pagination = () => {
const {pagination, dispatchAction, t} = useAppContext();
const labs = useLabs();
const loadMore = () => {
Function handleSave
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const handleSave = useCallback<SaveHandler>(async (options = {}) => {
if (!validate()) {
setSaveState('error');
return false;
}
Function getRelativeTimestamp
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const getRelativeTimestamp = (date: Date): string => {
const now = new Date();
const seconds = Math.floor((now.getTime() - date.getTime()) / 1000);
let interval = Math.floor(seconds / 31536000);
Consider simplifying this complex logical expression. Open
Open
if (!socketAddress || !socketAddress.host || !socketAddress.port || !logging || !logging.info || !logging.warn || !message) {
return Promise.resolve();
}
Function permissible
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
async permissible(commentModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission, hasMemberPermission) {
Consider simplifying this complex logical expression. Open
Open
if (center) {
const centerClasses = clsx(
'flex flex-auto items-center justify-center',
(left && right) && 'basis-1/3',
((left && !right) || (!left && right)) && 'basis-1/2'
Consider simplifying this complex logical expression. Open
Open
if (previewToolbar) {
let toolbarLeft = (<></>);
if (previewToolbarURLs) {
toolbarLeft = (
<Select
Function compare
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
compare(postA, postB) {
let updated1 = postA.get('updatedAtUTC');
let updated2 = postB.get('updatedAtUTC');
let idResult,
publishedAtResult,
- 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"