catarse/mithril-postgrest

View on GitHub

Showing 11 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

            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

              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
                    Severity
                    Category
                    Status
                    Source
                    Language