catarse/mithril-postgrest

View on GitHub

Showing 19 of 19 total issues

Function filtersVM has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
Open

export default function filtersVM(attributes) {
    const newVM = {} as Filter
    const filter = () : Filter => {
        const innerProp = prop('')
        const filterProp = function (value? : any ) : string | Filter  {
Severity: Minor
Found in src/vms/filtersVM.ts - About 1 day 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 Postgrest has 208 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function Postgrest(mithrilInstance) {
    const m = mithrilInstance || mithril;
    const locker = new ExecutionLocker()
    const postgrest = {} as InnerPostgrestData

Severity: Major
Found in src/postgrest.ts - About 1 day to fix

    Function init has 163 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        postgrest.init = (apiPrefix, authenticationOptions, globalHeader = {}, isExpired = defaultIsTokenExpired) => {
            postgrest.request = (options) => {
                const errorHandler = (xhr) => {
                    try {
                        return JSON.parse(xhr.responseText)
    Severity: Major
    Found in src/postgrest.ts - About 6 hrs to fix

      Function model has 112 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              postgrest.model = (name) => {
                  const paginationHeaders = (page, pageSize) => {
                      if (!pageSize) {
                          return
                      }
      Severity: Major
      Found in src/postgrest.ts - About 4 hrs to fix

        Function Postgrest has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function Postgrest(mithrilInstance) {
            const m = mithrilInstance || mithril;
            const locker = new ExecutionLocker()
            const postgrest = {} as InnerPostgrestData
        
        
        Severity: Minor
        Found in src/postgrest.ts - 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

        Function filtersVM has 91 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function filtersVM(attributes) {
            const newVM = {} as Filter
            const filter = () : Filter => {
                const innerProp = prop('')
                const filterProp = function (value? : any ) : string | Filter  {
        Severity: Major
        Found in src/vms/filtersVM.ts - About 3 hrs to fix

          Function paginationVM has 79 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default function paginationVM(mithilInstance) {
              const m = mithilInstance;
              return (model, order, extraHeaders = {}, authenticate = true) => {
                  const collection = prop([])
                  const defaultOrder = order || 'id.desc'
          Severity: Major
          Found in src/vms/paginationVM.ts - About 3 hrs to fix

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

                private async rejectAllWithErroOnKey(key : string, error : Error) {
                    if (key in this.promisesInternalResolversRejecters) {
                        const rejecters = this.promisesInternalResolversRejecters[key].map(({ reject }) => reject)
                        for (const rejectWith of rejecters) {
                            rejectWith(error)
            Severity: Major
            Found in src/utils/execution-locker.ts and 1 other location - About 2 hrs to fix
            src/utils/execution-locker.ts on lines 30..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 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

                private async resolveAllWithResultOnKey(key : string, result : any) : Promise<void> {
                    if (key in this.promisesInternalResolversRejecters) {
                        const resolvers = this.promisesInternalResolversRejecters[key].map(({ resolve }) => resolve)
                        for (const resolveWith of resolvers) {
                            resolveWith(result)
            Severity: Major
            Found in src/utils/execution-locker.ts and 1 other location - About 2 hrs to fix
            src/utils/execution-locker.ts on lines 58..67

            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

            File postgrest.ts has 269 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import prop from 'mithril/stream';
            import _ from 'underscore';
            import filtersVM, { Filter } from './vms/filtersVM';
            import paginationVM from './vms/paginationVM';
            import mithril from 'mithril';
            Severity: Minor
            Found in src/postgrest.ts - About 2 hrs to fix

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

                          try {
                              return JSON.parse(xhr.responseText)
                          } catch (ex) {
                              return JSON.stringify({
                                  hint: null,
              Severity: Major
              Found in src/vms/paginationVM.ts and 1 other location - About 1 hr to fix
              src/postgrest.ts on lines 123..132

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

              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

                              try {
                                  return JSON.parse(xhr.responseText)
                              } catch (ex) {
                                  return JSON.stringify({
                                      hint: null,
              Severity: Major
              Found in src/postgrest.ts and 1 other location - About 1 hr to fix
              src/vms/paginationVM.ts on lines 71..80

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

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

                  const parametersWithoutOrder = () => {
                      return _.reduce(getters, (memo, getter : Filter, attr) => {
                          if (attr !== 'order') {
                              const operator = attributes[attr]
              
              
              Severity: Minor
              Found in src/vms/filtersVM.ts - About 1 hr to fix

                Function filter has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    const filter = () : Filter => {
                        const innerProp = prop('')
                        const filterProp = function (value? : any ) : string | Filter  {
                            if (arguments.length > 0) {
                                innerProp(value)
                Severity: Minor
                Found in src/vms/filtersVM.ts - About 1 hr to fix

                  Function getTotal has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          const getTotal = (xhr) => {
                              if (!xhr || xhr.status === 0) {
                                  return JSON.stringify({
                                      hint: null,
                                      details: null,
                  Severity: Minor
                  Found in src/vms/paginationVM.ts - About 1 hr to fix

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

                                    patch(filters: any, attributes: any, options: any, headers?: {}) {
                                        return postgrest.request(patchOptions(filters, attributes, options, headers))
                                    },
                    Severity: Major
                    Found in src/postgrest.ts and 3 other locations - About 35 mins to fix
                    src/postgrest.ts on lines 268..270
                    src/postgrest.ts on lines 283..285
                    src/postgrest.ts on lines 289..291

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

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

                                    getPage(data: any, page: any, options: any, headers?: {}) {
                                        return postgrest.request(getPageOptions(data, page, options, headers))
                                    },
                    Severity: Major
                    Found in src/postgrest.ts and 3 other locations - About 35 mins to fix
                    src/postgrest.ts on lines 274..276
                    src/postgrest.ts on lines 283..285
                    src/postgrest.ts on lines 289..291

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

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

                                    patchWithToken(filters: any, attributes: any, options: any, headers?: {}) {
                                        return postgrest.requestWithToken(patchOptions(filters, attributes, options, headers))
                                    },
                    Severity: Major
                    Found in src/postgrest.ts and 3 other locations - About 35 mins to fix
                    src/postgrest.ts on lines 268..270
                    src/postgrest.ts on lines 274..276
                    src/postgrest.ts on lines 283..285

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

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

                                    getPageWithToken(data: any, page: any, options: any, headers?: {}) {
                                        return postgrest.requestWithToken(getPageOptions(data, page, options, headers))
                                    },
                    Severity: Major
                    Found in src/postgrest.ts and 3 other locations - About 35 mins to fix
                    src/postgrest.ts on lines 268..270
                    src/postgrest.ts on lines 274..276
                    src/postgrest.ts on lines 289..291

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

                    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