lowdefy/lowdefy

View on GitHub

Showing 9,042 of 9,129 total issues

File Blocks.js has 555 lines of code (exceeds 250 allowed). Consider refactoring.
Confirmed

/* eslint-disable no-param-reassign */

/*
  Copyright 2020-2024 Lowdefy, Inc

Severity: Major
Found in packages/engine/src/Blocks.js - About 1 day to fix

    Identical blocks of code found in 3 locations. Consider refactoring.
    Open

    async function handler({ context, req, res }) {
      if (req.method !== 'POST') {
        throw new Error('Only POST requests are supported.');
      }
      const { pageId, requestId } = req.query;
    packages/servers/server-dev/pages/api/request/[pageId]/[requestId].js on lines 21..30
    packages/servers/server-enterprise/pages/api/request/[pageId]/[requestId].js on lines 15..24

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 181.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 3 locations. Consider refactoring.
    Open

    async function handler({ context, req, res }) {
      if (req.method !== 'POST') {
        throw new Error('Only POST requests are supported.');
      }
      const { pageId, requestId } = req.query;
    packages/servers/server-community/pages/api/request/[pageId]/[requestId].js on lines 21..30
    packages/servers/server-dev/pages/api/request/[pageId]/[requestId].js on lines 21..30

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 181.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 3 locations. Consider refactoring.
    Open

    async function handler({ context, req, res }) {
      if (req.method !== 'POST') {
        throw new Error('Only POST requests are supported.');
      }
      const { pageId, requestId } = req.query;
    packages/servers/server-community/pages/api/request/[pageId]/[requestId].js on lines 21..30
    packages/servers/server-enterprise/pages/api/request/[pageId]/[requestId].js on lines 15..24

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 181.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    module.exports = withLess({
      basePath: lowdefyConfig.basePath,
      reactStrictMode: true,
      webpack: (config, { isServer }) => {
        if (!isServer) {
    Severity: Major
    Found in packages/servers/server-enterprise/next.config.js and 1 other location - About 6 hrs to fix
    packages/servers/server-community/next.config.js on lines 4..29

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 170.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    module.exports = withLess({
      basePath: lowdefyConfig.basePath,
      reactStrictMode: true,
      webpack: (config, { isServer }) => {
        if (!isServer) {
    Severity: Major
    Found in packages/servers/server-community/next.config.js and 1 other location - About 6 hrs to fix
    packages/servers/server-enterprise/next.config.js on lines 4..29

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 170.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function getter has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Confirmed

    function getter(target, path, options) {
      if (typeTest.isNone(path) || !isValidObject(target)) {
        return typeof options.default !== 'undefined' ? options.default : undefined;
      }
    
    
    Severity: Minor
    Found in packages/utils/helpers/src/get.js - About 6 hrs 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 init has 144 lines of code (exceeds 25 allowed). Consider refactoring.
    Confirmed

      init(initState) {
        this.loopBlocks((block) => {
          block.idPattern = block.id;
          block.blockIdPattern = block.blockId;
          block.id = applyArrayIndices(this.arrayIndices, block.idPattern);
    Severity: Major
    Found in packages/engine/src/Blocks.js - About 5 hrs to fix

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      function Session({ children }) {
        const wasAuthenticated = useRef(false);
        const { data: session, status } = useSession();
        wasAuthenticated.current = wasAuthenticated.current || status === 'authenticated';
      
      
      packages/servers/server-dev/lib/client/auth/AuthConfigured.js on lines 23..41

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 147.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      function Session({ children }) {
        const wasAuthenticated = useRef(false);
        const { data: session, status } = useSession();
        wasAuthenticated.current = wasAuthenticated.current || status === 'authenticated';
      
      
      packages/servers/server-enterprise/lib/client/auth/AuthConfigured.js on lines 18..36

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 147.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function recEval has 123 lines of code (exceeds 25 allowed). Consider refactoring.
      Confirmed

        recEval(visibleParent) {
          let repeat = false;
          this.loopBlocks((block) => {
            if (block.meta.category === 'input') {
              const stateValue = get(this.context.state, block.blockId);
      Severity: Major
      Found in packages/engine/src/Blocks.js - About 4 hrs to fix

        Function stableStringify has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Confirmed

        function stableStringify(obj, opts) {
          if (!opts) opts = {};
          if (typeof opts === 'function') opts = { cmp: opts };
          let space = opts.space || '';
          if (typeof space === 'number') space = Array(space + 1).join(' ');
        Severity: Minor
        Found in packages/utils/helpers/src/stableStringify.js - About 4 hrs 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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

          useEffect(() => {
            methods.registerMethod(get(rename, 'methods.toggleOpen', { default: 'toggleOpen' }), () =>
              triggerSetOpen({ state: !openState, setOpen, methods, rename })
            );
            methods.registerMethod(get(rename, 'methods.setOpen', { default: 'setOpen' }), ({ open }) =>
        packages/plugins/blocks/blocks-antd/src/blocks/Sider/Sider.js on lines 36..43

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 129.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

          useEffect(() => {
            methods.registerMethod(get(rename, 'methods.toggleOpen', { default: 'toggleOpen' }), () =>
              triggerSetOpen({ state: !openState, setOpen, methods, rename })
            );
            methods.registerMethod(get(rename, 'methods.setOpen', { default: 'setOpen' }), ({ open }) =>
        packages/plugins/blocks/blocks-antd/src/blocks/Drawer/Drawer.js on lines 35..42

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 129.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function createLinkComponent has 112 lines of code (exceeds 25 allowed). Consider refactoring.
        Confirmed

        const createLinkComponent = (lowdefy, Link) => {
          const { window } = lowdefy._internal.globals;
          const backLink = ({ ariaLabel, children, className, id, onClick = () => {}, rel }) => (
            <a
              id={id}
        Severity: Major
        Found in packages/client/src/createLinkComponent.js - About 4 hrs to fix

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          export async function getStaticProps() {
            // Important to give absolute path so Next can trace build files
            const context = {
              buildDirectory: path.join(process.cwd(), 'build'),
              config,
          Severity: Major
          Found in packages/servers/server-community/pages/404.js and 1 other location - About 4 hrs to fix
          packages/servers/server-enterprise/pages/404.js on lines 18..39

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 124.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          export async function getStaticProps() {
            // Important to give absolute path so Next can trace build files
            const context = {
              buildDirectory: path.join(process.cwd(), 'build'),
              config,
          Severity: Major
          Found in packages/servers/server-enterprise/pages/404.js and 1 other location - About 4 hrs to fix
          packages/servers/server-community/pages/404.js on lines 23..44

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 124.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function RatingSlider has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
          Open

          const RatingSlider = ({
            blockId,
            components: { Icon, Link },
            events,
            loading,

          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 PageSiderMenu.js has 349 lines of code (exceeds 250 allowed). Consider refactoring.
          Confirmed

          /*
            Copyright 2020-2024 Lowdefy, Inc
          
            Licensed under the Apache License, Version 2.0 (the "License");
            you may not use this file except in compliance with the License.

            Function runClass has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Confirmed

            const runClass = ({ location, meta, methodName, operator, params, functions, defaultFunction }) => {
              if (!methodName) {
                if (meta[params]) {
                  methodName = params;
                } else if (defaultFunction) {
            Severity: Minor
            Found in packages/operators/src/runClass.js - About 3 hrs 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