danielwii/asuna-admin

View on GitHub

Showing 310 of 310 total issues

Function AsunaDataTable has 343 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const AsunaDataTable: React.FC<AsunaDataTableProps> = (props) => {
  const {
    creatable = false,
    editable = false,
    deletable = false,
Severity: Major
Found in src/components/AsunaDataTable.tsx - About 1 day to fix

    File model.ts has 490 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { parseJSONIfCould } from '@danielwii/asuna-helper/dist/utils';
    import { ApiResponse } from '@danielwii/asuna-shared';
    
    import { message } from 'antd';
    import { Promise } from 'bluebird';
    Severity: Minor
    Found in src/adapters/model.ts - About 7 hrs to fix

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

        async loadOriginSchemas(): Promise<{ [name: string]: Asuna.Schema.OriginSchema }> {
          if (this.graphql.client) {
            const allResponse = await this.graphql.loadSchemas();
            return Object.assign({}, ..._.map(allResponse, ({ name, schema }) => ({ [name]: schema })));
          } else {
      Severity: Major
      Found in src/adapters/model.ts and 1 other location - About 7 hrs to fix
      src/adapters/model.ts on lines 607..616

      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 189.

      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

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

        async loadSchemas() {
          if (this.graphql.client) {
            const allResponse = await this.graphql.loadSchemas();
            return Object.assign({}, ..._.map(allResponse, ({ name, schema }) => ({ [name]: schema })));
          } else {
      Severity: Major
      Found in src/adapters/model.ts and 1 other location - About 7 hrs to fix
      src/adapters/model.ts on lines 596..605

      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 189.

      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

      File columns.tsx has 484 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { LinkOutlined, SearchOutlined } from '@ant-design/icons';
      import { css } from '@emotion/css';
      
      import {
        Badge,
      Severity: Minor
      Found in src/helpers/columns/columns.tsx - About 7 hrs to fix

        File upsert.tsx has 476 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import useLogger from '@danielwii/asuna-helper/dist/logger/hooks';
        
        import * as _ from 'lodash';
        import moment from 'moment';
        import * as R from 'ramda';
        Severity: Minor
        Found in src/modules/content/upsert.tsx - About 7 hrs to fix

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

          export const generateFile = (
            form: FormInstance,
            options,
            formItemLayout: IFormItemLayout = horizontalFormItemLayout,
          ) => {
          Severity: Major
          Found in src/components/DynamicForm/elements/Files.tsx and 1 other location - About 6 hrs to fix
          src/components/DynamicForm/elements/Files.tsx on lines 32..50

          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 165.

          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

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

          export const generateFiles = (
            form: FormInstance,
            options,
            formItemLayout: IFormItemLayout = horizontalFormItemLayout,
          ) => {
          Severity: Major
          Found in src/components/DynamicForm/elements/Files.tsx and 1 other location - About 6 hrs to fix
          src/components/DynamicForm/elements/Files.tsx on lines 12..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 165.

          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

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

              upload(file, {}, { bucket }).then((uploaded) => {
                if (uploaded) {
                  logger.log('[VideoUploader][customRequest]', { props: this.props, state: this.state });
                  const resolvedUrl = urlHandler ? urlHandler(uploaded[0]) : `${uploaded[0]}`;
                  const videos = this.valueToSubmit(this.props.value, resolvedUrl);
          Severity: Major
          Found in src/components/DynamicForm/Videos.tsx and 1 other location - About 6 hrs to fix
          src/components/DynamicForm/ImageUploader.tsx on lines 132..141

          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 161.

          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

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

              upload(option.file, uploadOpts ?? ({ bucket } as any), { bucket }).then((uploaded) => {
                if (uploaded) {
                  logger.log('[ImageUploader][customRequest]', { props: this.props, state: this.state });
                  const resolvedUrl = urlHandler ? urlHandler(uploaded[0]) : `${uploaded[0]}`;
                  const images = this.valueToSubmit(this.props.value, resolvedUrl);
          Severity: Major
          Found in src/components/DynamicForm/ImageUploader.tsx and 1 other location - About 6 hrs to fix
          src/components/DynamicForm/Videos.tsx on lines 89..98

          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 161.

          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 TenantWelcome has 153 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const TenantWelcome: React.FC = (props) => {
            const [count, reload] = useState(0);
            const { store } = useContext(StoreContext);
            const { value, error, loading } = useAsync(async () => {
              return Promise.props({
          Severity: Major
          Found in src/tenant/Welcome.tsx - About 6 hrs to fix

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

                    <Input.TextArea
                      value={typeof videos === 'string' ? videos : videos ? JSON.stringify(videos) : ''}
                      autoSize={{ minRows: 2, maxRows: 6 }}
                      onChange={(event) => {
                        logger.debug('[onChange]', event);
            Severity: Major
            Found in src/components/DynamicForm/Videos.tsx and 1 other location - About 5 hrs to fix
            src/components/DynamicForm/ImageUploader.tsx on lines 182..190

            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 153.

            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

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

                    <Input.TextArea
                      value={typeof value === 'string' ? value : value ? JSON.stringify(value) : ''}
                      autoSize={{ minRows: 2, maxRows: 6 }}
                      onChange={(event) => {
                        logger.debug('[onChange]', event);
            Severity: Major
            Found in src/components/DynamicForm/ImageUploader.tsx and 1 other location - About 5 hrs to fix
            src/components/DynamicForm/Videos.tsx on lines 138..146

            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 153.

            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

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

                    } else if (opts.mode === 'json') {
                      if (_.isArray(extracted)) {
                        view = (
                          <>
                            <List size="small">
            Severity: Major
            Found in src/helpers/columns/generator.tsx and 1 other location - About 5 hrs to fix
            src/helpers/index.tsx on lines 89..112

            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 148.

            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

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

                    } else if (opts.mode === 'json') {
                      view = extracted ? (
                        <Button
                          size="small"
                          type="dashed"
            Severity: Major
            Found in src/helpers/index.tsx and 1 other location - About 5 hrs to fix
            src/helpers/columns/generator.tsx on lines 112..171

            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 148.

            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

            File AsunaDataTable.tsx has 389 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { InfoOutlined, SyncOutlined } from '@ant-design/icons';
            
            import useLogger from '@danielwii/asuna-helper/dist/logger/hooks';
            import { parseJSONIfCould } from '@danielwii/asuna-helper/dist/utils';
            
            
            Severity: Minor
            Found in src/components/AsunaDataTable.tsx - About 5 hrs to fix

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

                        <>
                          <Col span={6}>
                            <Statistic title="+" value={item.change} valueStyle={{ color: '#3f8600' }} prefix={<ArrowUpOutlined />} />
                          </Col>
                          <Col>
              Severity: Major
              Found in src/components/Timeline.tsx and 1 other location - About 5 hrs to fix
              src/components/Timeline.tsx on lines 76..92

              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 141.

              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

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

                        <>
                          <Col span={6}>
                            <Statistic
                              title="-"
                              value={item.change}
              Severity: Major
              Found in src/components/Timeline.tsx and 1 other location - About 5 hrs to fix
              src/components/Timeline.tsx on lines 63..74

              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 141.

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

              export const AsunaDataTable: React.FC<AsunaDataTableProps> = (props) => {
                const {
                  creatable = false,
                  editable = false,
                  deletable = false,
              Severity: Minor
              Found in src/components/AsunaDataTable.tsx - About 5 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

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

                  _extractName = item => {
                    if (enumSelector.name) {
                      if (_.isString(enumSelector.name)) {
                        logger.warn("enumSelector.name is string, not function", enumSelector);
                      }
              Severity: Major
              Found in src/components/DynamicForm/elements/Select.tsx and 1 other location - About 5 hrs to fix
              src/components/DynamicForm/elements/Select.tsx on lines 157..168

              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 140.

              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

              Severity
              Category
              Status
              Source
              Language