alibaba/noform

View on GitHub
packages/core/src/index.ts

Summary

Maintainability
F
1 wk
Test Coverage

Function createList has 589 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createList(props: IListProps = {}): IList {
  // 渲染相关的设置都在API层完成,core层只管数据,和操作数据的方法
  const list = new ListCore(props)
  const lifeCycles = new LifeCylcesCore({ lifeCycles: props.lifeCycles })

Severity: Major
Found in packages/core/src/index.ts - About 2 days to fix

    Function createList has a Cognitive Complexity of 112 (exceeds 5 allowed). Consider refactoring.
    Open

    function createList(props: IListProps = {}): IList {
      // 渲染相关的设置都在API层完成,core层只管数据,和操作数据的方法
      const list = new ListCore(props)
      const lifeCycles = new LifeCylcesCore({ lifeCycles: props.lifeCycles })
    
    
    Severity: Minor
    Found in packages/core/src/index.ts - About 2 days 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

    File index.ts has 613 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import ListCore from './model/core'
    import LifeCylcesCore, { ListLifeCycle } from './model/lifeCycles'
    import {
      IList,
      IListFunctionOptions,
    Severity: Major
    Found in packages/core/src/index.ts - About 1 day to fix

      Function fetch has 149 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const fetch = async (extraFilterData?: IListFilterData) => {
          if (mode === ModeType.DATASOURCE) {
            return
          }
      
      
      Severity: Major
      Found in packages/core/src/index.ts - About 5 hrs to fix

        Function getFilterEffects has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const getFilterEffects = props => {
            const noop = () => {}
            const { effects = noop } = props || {}
            return ($, actions) => {
              // 搜索区域初始化完成
        Severity: Minor
        Found in packages/core/src/index.ts - About 1 hr to fix

          Function initSyncFilterData has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            const initSyncFilterData = (executeNow = false) => {
              // 同步params到搜索区域上
              const syncFilterData = {}
              Object.keys(params || {}).forEach(paramField => {
                if (
          Severity: Minor
          Found in packages/core/src/index.ts - About 1 hr to fix

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

              const reset = (fnOpts?: IListFunctionOptions) => {
                // 生命周期:清理查询条件
                lifeCycles.notify({
                  type: ListLifeCycleTypes.ON_LIST_RESET,
                  ctx: listAPI
            Severity: Major
            Found in packages/core/src/index.ts and 1 other location - About 5 hrs to fix
            packages/core/src/index.ts on lines 280..296

            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

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

              const clear = (fnOpts?: IListFunctionOptions) => {
                // 生命周期:清理查询条件
                lifeCycles.notify({
                  type: ListLifeCycleTypes.ON_LIST_CLEAR,
                  ctx: listAPI
            Severity: Major
            Found in packages/core/src/index.ts and 1 other location - About 5 hrs to fix
            packages/core/src/index.ts on lines 299..317

            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

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

              const setMultipleData = (
                multipleData: IListMultipleDataParams,
                fnOpts?: IListFunctionOptions
              ) => {
                const multipleKeys = Object.keys(multipleData)
            Severity: Major
            Found in packages/core/src/index.ts and 1 other location - About 2 hrs to fix
            packages/core/src/index.ts on lines 408..419

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

            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

              const setMultiplePageSize = (
                multiplePageSize: IListMultiplePageSize,
                fnOpts?: IListFunctionOptions
              ) => {
                const multipleKeys = Object.keys(multiplePageSize)
            Severity: Major
            Found in packages/core/src/index.ts and 1 other location - About 2 hrs to fix
            packages/core/src/index.ts on lines 394..405

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

            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

                  $('onFormSubmitValidateSuccess').subscribe(state => {
                    const { errors, warnings } = state
                    lifeCycles.notify({
                      type: ListLifeCycleTypes.ON_LIST_VALIDATE_END,
                      ctx: listAPI,
            Severity: Major
            Found in packages/core/src/index.ts and 1 other location - About 2 hrs to fix
            packages/core/src/index.ts on lines 539..546

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

            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

                  $('onFormSubmitValidateFailed').subscribe(state => {
                    const { errors, warnings } = state
                    lifeCycles.notify({
                      type: ListLifeCycleTypes.ON_LIST_VALIDATE_END,
                      ctx: listAPI,
            Severity: Major
            Found in packages/core/src/index.ts and 1 other location - About 2 hrs to fix
            packages/core/src/index.ts on lines 549..556

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

            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 3 locations. Consider refactoring.
            Open

                  $('onFormMount').subscribe(state => {
                    lifeCycles.notify({
                      type: ListLifeCycleTypes.ON_LIST_FILTER_MOUNT,
                      ctx: listAPI,
                      payload: state
            Severity: Major
            Found in packages/core/src/index.ts and 2 other locations - About 1 hr to fix
            packages/core/src/index.ts on lines 513..519
            packages/core/src/index.ts on lines 522..528

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

            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 3 locations. Consider refactoring.
            Open

                  $('onFieldValueChange').subscribe(state => {
                    lifeCycles.notify({
                      type: ListLifeCycleTypes.ON_LIST_FILTER_ITEM_CHANGE,
                      ctx: listAPI,
                      payload: state
            Severity: Major
            Found in packages/core/src/index.ts and 2 other locations - About 1 hr to fix
            packages/core/src/index.ts on lines 504..510
            packages/core/src/index.ts on lines 513..519

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

            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 3 locations. Consider refactoring.
            Open

                  $('onFormValuesChange').subscribe(state => {
                    lifeCycles.notify({
                      type: ListLifeCycleTypes.ON_LIST_FILTER_VALUES_CHANGE,
                      ctx: listAPI,
                      payload: state
            Severity: Major
            Found in packages/core/src/index.ts and 2 other locations - About 1 hr to fix
            packages/core/src/index.ts on lines 504..510
            packages/core/src/index.ts on lines 522..528

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

            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

                if (expandStatus === 'expand') {
                  expandStatus = 'collapse'
                  filterInstance.notify(ListLifeCycleTypes.ON_LIST_FILTER_ITEM_COLLAPSE)
                  lifeCycles.notify({
                    type: ListLifeCycleTypes.ON_LIST_FILTER_ITEM_COLLAPSE,
            Severity: Minor
            Found in packages/core/src/index.ts and 1 other location - About 50 mins to fix
            packages/core/src/index.ts on lines 570..577

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

            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 {
                  expandStatus = 'expand'
                  filterInstance.notify(ListLifeCycleTypes.ON_LIST_FILTER_ITEM_EXPAND)
                  lifeCycles.notify({
                    type: ListLifeCycleTypes.ON_LIST_FILTER_ITEM_EXPAND,
            Severity: Minor
            Found in packages/core/src/index.ts and 1 other location - About 50 mins to fix
            packages/core/src/index.ts on lines 563..570

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

            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

              const refreshPagination = (notifyId?: string[]) =>
                lifeCycles.notify({
                  type: ListLifeCycleTypes.ON_LIST_PAGINATION_REFRESH,
                  payload: { notifyId }
                })
            Severity: Minor
            Found in packages/core/src/index.ts and 1 other location - About 35 mins to fix
            packages/core/src/index.ts on lines 47..51

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

            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

              const refreshLoading = (notifyId?: string[]) =>
                lifeCycles.notify({
                  type: ListLifeCycleTypes.ON_LIST_LOADING_REFRESH,
                  payload: { notifyId }
                })
            Severity: Minor
            Found in packages/core/src/index.ts and 1 other location - About 35 mins to fix
            packages/core/src/index.ts on lines 52..56

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

            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

            There are no issues that match your filters.

            Category
            Status