TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function updateMember has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function updateMember({data, state, api}: {data: {name: string, expertise: string}, state: EditableAppContext, api: GhostApi}) {
    const {name, expertise} = data;
    const patchData: {name?: string, expertise?: string} = {};

    const originalName = state?.member?.name;
Severity: Minor
Found in apps/comments-ui/src/actions.ts - About 35 mins to fix

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 useOptions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function useOptions(scriptTag: HTMLElement) {
    const buildOptions = React.useCallback(() => {
        /**
         * @type {HTMLElement}
         */
Severity: Minor
Found in apps/comments-ui/src/utils/options.ts - About 35 mins to fix

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 adminXViteConfig has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export default function adminXViteConfig({packageName, entry, overrides}: {packageName: string; entry: string; overrides?: UserConfig}) {
    const outputFileName = packageName[0] === '@' ? packageName.slice(packageName.indexOf('/') + 1) : packageName;

    const defaultConfig = defineConfig({
        logLevel: process.env.CI ? 'info' : 'warn',
Severity: Minor
Found in apps/admin-x-framework/src/vite.ts - About 35 mins to fix

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 getFollowing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    async getFollowing(): Promise<Activity[]> {
        const json = await this.fetchJSON(this.followingApiUrl);
        if (json === null) {
            return [];
        }
Severity: Minor
Found in apps/admin-x-activitypub/src/api/activitypub.ts - About 35 mins to fix

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 MainNavigation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const MainNavigation: React.FC<MainNavigationProps> = ({
    page = '',
    onLayoutChange
}) => {
    const {route, updateRoute} = useRouting();
Severity: Minor
Found in apps/admin-x-activitypub/src/components/navigation/MainNavigation.tsx - About 35 mins to fix

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 PublishedComment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const PublishedComment: React.FC<CommentProps> = ({comment, parent, openEditMode, toggleParentReplyMode}) => {
    const [isInReplyMode, setIsInReplyMode] = useState(false);
    const {dispatchAction} = useAppContext();

    const toggleReplyMode = async () => {
Severity: Minor
Found in apps/comments-ui/src/components/content/Comment.tsx - About 35 mins to fix

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 7 (exceeds 5 allowed). Consider refactoring.
Open

const Form: React.FC<FormProps> = ({isMinimal, loading, success, error, buttonColor, buttonTextColor, onSubmit}) => {
    const [email, setEmail] = React.useState('');
    const {t} = useAppContext();

    const submitHandler: FormEventHandler<HTMLFormElement> = (e) => {
Severity: Minor
Found in apps/signup-form/src/components/pages/FormView.tsx - About 35 mins to fix

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 FormPage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const FormPage: React.FC = () => {
    const [error, setError] = React.useState('');
    const [loading, setLoading] = React.useState(false);
    const [success, setSuccess] = React.useState(false);
    const {api, setPage, options, t} = useAppContext();
Severity: Minor
Found in apps/signup-form/src/components/pages/FormPage.tsx - About 35 mins to fix

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 getOutbox has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    async getOutbox(): Promise<Activity[]> {
        const json = await this.fetchJSON(this.outboxApiUrl);
        if (json === null) {
            return [];
        }
Severity: Minor
Found in apps/admin-x-activitypub/src/api/activitypub.ts - About 35 mins to fix

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 CodeEditorView has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const CodeEditorView = forwardRef<ReactCodeMirrorRef, CodeEditorProps>(function CodeEditorView({
    title,
    value,
    height = '200px',
    error,
Severity: Minor
Found in apps/admin-x-design-system/src/global/form/CodeEditorView.tsx - About 35 mins to fix

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 getInbox has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    async getInbox(): Promise<Activity[]> {
        const json = await this.fetchJSON(this.inboxApiUrl);
        if (json === null) {
            return [];
        }
Severity: Minor
Found in apps/admin-x-activitypub/src/api/activitypub.ts - About 35 mins to fix

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 DesktopChromeHeader has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const DesktopChromeHeader: React.FC<DesktopChromeHeaderProps & React.HTMLAttributes<HTMLDivElement>> = ({
    size = 'md',
    toolbarLeft = '',
    toolbarCenter = '',
    toolbarRight = '',
Severity: Minor
Found in apps/admin-x-design-system/src/global/chrome/DesktopChromeHeader.tsx - About 35 mins to fix

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 adminXPlaywrightConfig has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function adminXPlaywrightConfig(overrides: Partial<PlaywrightTestConfig> = {}) {
    /**
     * See https://playwright.dev/docs/test-configuration.
     */
    return defineConfig({
Severity: Minor
Found in apps/admin-x-framework/src/playwright.ts - About 35 mins to fix

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 updateQueryCache has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const updateQueryCache = <ResponseData>(field: string, updatedRecords?: (response: ResponseData) => Record<string, unknown>) => {
    return (newData: ResponseData, currentData: unknown) => {
        if (!currentData) {
            return currentData;
        }
Severity: Minor
Found in apps/admin-x-framework/src/utils/api/updateQueries.ts - About 35 mins to fix

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

Avoid too many return statements within this function.
Open

                    return {
                        referrerSource: urlData?.source ?? null,
                        referrerMedium: urlData?.medium ?? null,
                        referrerUrl: referrerUrl?.hostname ?? null
                    };
Severity: Major
Found in ghost/member-attribution/lib/ReferrerTranslator.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                        return;

      Avoid too many return statements within this function.
      Open

                      return 'reactivated paid subscription';
      Severity: Major
      Found in ghost/admin/app/helpers/parse-member-event.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return `clicked ${ghPluralize(event.data.count.clicks, 'link')} in email`;
        Severity: Major
        Found in ghost/admin/app/helpers/parse-member-event.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return time.format(`[Yesterday]`);
          Severity: Major
          Found in ghost/admin/app/helpers/gh-format-post-time.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return url;
            Severity: Major
            Found in ghost/member-attribution/lib/OutboundLinkTagger.js - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language