TryGhost/Ghost

View on GitHub

Showing 1,820 of 4,015 total issues

Function Toast has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const Toast: React.FC<ToastProps> = ({
    t,
    children,
    props
}) => {
Severity: Minor
Found in apps/admin-x-design-system/src/global/Toast.tsx - About 55 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 RoutingProvider has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export const RoutingProvider: React.FC<RoutingProviderProps> = ({basePath, modals, children}) => {
    const {externalNavigate} = useFramework();
    const [route, setRoute] = useState<string | undefined>(undefined);
    const [loadingModal, setLoadingModal] = useState(false);
    const [eventTarget] = useState(new EventTarget());
Severity: Minor
Found in apps/admin-x-framework/src/providers/RoutingProvider.tsx - About 55 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 createPaginatedQuery has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export const createPaginatedQuery = <ResponseData extends {meta?: Meta}>(options: QueryOptions<ResponseData>) => ({searchParams, ...query}: QueryHookOptions<ResponseData> = {}) => {
    const [page, setPage] = useState(1);
    const limit = (searchParams?.limit || options.defaultSearchParams?.limit) ? parseInt(searchParams?.limit || options.defaultSearchParams?.limit || '15') : 15;

    const paginatedSearchParams = searchParams || options.defaultSearchParams || {};
Severity: Minor
Found in apps/admin-x-framework/src/utils/api/hooks.ts - About 55 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 FileUpload has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const FileUpload: React.FC<FileUploadProps> = ({id, onUpload, children, style, unstyled = false, inputRef, className, dragIndicatorClassName, ...props}) => {
    const [fileKey, setFileKey] = useState<number>(Date.now());
    const [isDragging, setIsDragging] = useState(false);

    const handleFileChange = (event: ChangeEvent<HTMLInputElement>) => {
Severity: Minor
Found in apps/admin-x-design-system/src/global/form/FileUpload.tsx - About 55 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 KoenigWrapper has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const KoenigWrapper: React.FC<HtmlEditorProps & { editor: EditorResource }> = ({
    editor,
    value,
    onChange,
    onBlur,
Severity: Minor
Found in apps/admin-x-design-system/src/global/form/HtmlEditor.tsx - About 55 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 DynamicTable has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const DynamicTable: React.FC<DynamicTableProps> = ({
    columns,
    rows,
    horizontalScrolling = false,
    absolute = false,
Severity: Minor
Found in apps/admin-x-design-system/src/global/table/DynamicTable.tsx - About 55 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 HtmlField has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const HtmlField: React.FC<HtmlFieldProps> = ({
    title,
    hideTitle,
    error,
    hint,
Severity: Minor
Found in apps/admin-x-design-system/src/global/form/HtmlField.tsx - About 55 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 getActivities has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    async getActivities(
        includeOwn: boolean = false,
        includeReplies: boolean = false,
        excludeNonFollowers: boolean = false,
        filter: {type?: string[]} | null = null,
Severity: Minor
Found in apps/admin-x-activitypub/src/api/activitypub.ts - About 55 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 ListPage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const ListPage = () => {
    const {updateRoute} = useRouting();
    const [view, setView] = useState<string>('list');

    const dummyActions = [
Severity: Minor
Found in apps/admin-x-demo/src/ListPage.tsx - About 55 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 viteConfig has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export default (function viteConfig() {
    return defineConfig({
        logLevel: process.env.CI ? 'info' : 'warn',
        plugins: [
            react()
Severity: Minor
Found in apps/admin-x-framework/vite.config.ts - About 55 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 permissible has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

        permissible: function permissible(postModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
Severity: Major
Found in ghost/core/core/server/models/relations/authors.js - About 50 mins to fix

    Function permissible has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        permissible: function permissible(roleModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
    Severity: Major
    Found in ghost/core/core/server/models/role.js - About 50 mins to fix

      Function permissible has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          async permissible(inviteModel, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
      Severity: Major
      Found in ghost/core/core/server/models/invite.js - About 50 mins to fix

        Function permissible has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            permissible: async function permissible(postModel, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
        Severity: Major
        Found in ghost/core/core/server/models/post.js - About 50 mins to fix

          Function permissible has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              async permissible(integrationModel, action, context, attrs, loadedPerms, hasUserPermission, hasApiKeyPermission) {
          Severity: Major
          Found in ghost/core/core/server/models/integration.js - About 50 mins to fix

            Function permissible has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                permissible: async function permissible(userModelOrId, action, context, unsafeAttrs, loadedPermissions, hasUserPermission, hasApiKeyPermission) {
            Severity: Major
            Found in ghost/core/core/server/models/user.js - About 50 mins to fix

              Function rand has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function rand(min, max) {
                  var key, value, arr = new Uint8Array(max);
                  getRandomValues(arr);
                  for (key in arr) {
                      if (Object.prototype.hasOwnProperty.call(arr, key)) {
              Severity: Minor
              Found in ghost/admin/app/utils/password-generator.js - About 45 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 buildQuery has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  buildQuery(store, modelName, options) {
                      let deDupe = {};
                      let toInclude = this.getEmbeddedRelations(store, modelName);
                      let query = options || {};
              
              
              Severity: Minor
              Found in ghost/admin/app/adapters/embedded-relation-adapter.js - About 45 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 toggleEventType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              export function toggleEventType(eventType, eventTypes) {
                  const excludedEvents = new Set(eventTypes.filter(type => !type.isSelected).map(type => type.event));
              
                  if (eventType === 'payment_event') {
                      if (excludedEvents.has('payment_event')) {
              Severity: Minor
              Found in ghost/admin/app/utils/member-event-types.js - About 45 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  static create(type, months) {
                      if (!type || typeof type !== 'string') {
                          throw new InvalidOfferDuration({
                              message: 'Offer `duration` must be a string.'
                          });
              Severity: Minor
              Found in ghost/offers/lib/domain/models/OfferDuration.js - About 45 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

              Severity
              Category
              Status
              Source
              Language