beattyml1/metatonic-platform

View on GitHub

Showing 24 of 77 total issues

Function createValueStoreDataType has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

export function createValueStoreDataType<T>(parse: (inputString: string, format?: string) => T, format: (val: T, format?: string) => string) {
    return class BaseValueDataType implements ComparableValueDataType {
        value: T|null;

        static fromData(value: string, field?: SchemaField, Class?: new () => BaseValueDataType) {
Severity: Minor
Found in metatonic-core/src/data/BaseValueDataType.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 matchesFilter has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

let matchesFilter = (filter) => (value) => {
    return Object.keys(filter).every((key) => {
        if (!isKnown(filter[key])) return true;
        if (filter[key] === value[key]) return true;
        if (typeof value[key] === 'object') return matchesFilter(filter[key])(value[key]);
Severity: Minor
Found in metatonic-core/src/state/LocalStorageDataStore.ts - About 2 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 createValueStoreDataType has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function createValueStoreDataType<T>(parse: (inputString: string, format?: string) => T, format: (val: T, format?: string) => string) {
    return class BaseValueDataType implements ComparableValueDataType {
        value: T|null;

        static fromData(value: string, field?: SchemaField, Class?: new () => BaseValueDataType) {
Severity: Minor
Found in metatonic-core/src/data/BaseValueDataType.ts - About 2 hrs to fix

    Function dataTypeForType has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    export function dataTypeForType(type: SchemaType) {
        if (type.category === SchemaTypeCategory.Numeric) {
            let numericParams = type.parameters as NumericTypeInfo;
            if (numericParams.isInteger) return Integer;
            if (numericParams.isFloating) return Float;
    Severity: Minor
    Found in metatonic-core/src/services/DataTypeForField.ts - About 1 hr 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 addDefaultValidations has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function addDefaultValidations(field: SchemaFieldInfo): SchemaValidation[] {
        return [
            ...field.validations,
            ...addValidation(hasValue(field.min))({
                name: 'min',
    Severity: Minor
    Found in metatonic-core/src/services/SchemaFromJsonService.ts - About 1 hr to fix

      Function render has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          render() {
              let hardCodedUnit = this.type().unitSource.unit;
              let unitCategory = this.type().unitSource.unitCategory;
              let units = this.type().unitSource.units;
              let hasUnits = !!unitCategory;
      Severity: Minor
      Found in metatonic-react/src/Editors/QuantityEditor.tsx - About 1 hr 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 validateOnTimeMatch has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function validateOnTimeMatch(validation: SchemaValidation, time: ValidationTime, validate: Validation, value, field: SchemaField, params): ValidationResults {
      Severity: Minor
      Found in metatonic-core/src/services/ValidationUtils.ts - About 45 mins to fix

        Function addUnitData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            async addUnitData(field: SchemaField) {
                if (field.type.category !== SchemaTypeCategory.Quantity) return Promise.resolve();
        
                let type = field.type as QuantityType;
                let unitSpec = type.parameters.unitSource;
        Severity: Minor
        Found in metatonic-core/src/services/UnitService.ts - About 45 mins 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 createMetatonicAppInitializer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export function createMetatonicAppInitializer(config: MetatonicAppConfig){
            let o = config;
            let hasDefaultContext = o.dataStore && o.componentRegistry;
            let getAllKeys = (...maps: any[]) => new Set(maps.filter(_=>_).reduce((keys, map) => [...keys, Object.keys(map)], new Array<string>()));
            let allKeys = getAllKeys(o.dataStores, o.contexts, o.componentRegistries, hasDefaultContext ? { default: {} } : {});
        Severity: Minor
        Found in metatonic-redux/src/createMetatonicAppInitializer.ts - About 45 mins 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 getField has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        let getField = function (fieldTypeName: string, propertyKey: string, label: string, editSelect: SchemaEntryType, isMulti: boolean, options?: OptionalProps<SchemaField>) {
        Severity: Minor
        Found in metatonic-core/src/decorators/MetatonicModelDecorator.ts - About 45 mins to fix

          Function required has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          export const required: Validation = function required(value, field, validation, time, params)  {
          Severity: Minor
          Found in metatonic-core/src/services/BuiltInValidations.ts - About 35 mins to fix

            Function regexValidaiton has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            export const regexValidaiton: Validation<any> = function regex(value, field, validation, time, params)  {
            Severity: Minor
            Found in metatonic-core/src/services/BuiltInValidations.ts - About 35 mins to fix

              Function maxLength has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              export const maxLength: Validation = function maxLength(value, field, validation, time, params)  {
              Severity: Minor
              Found in metatonic-core/src/services/BuiltInValidations.ts - About 35 mins to fix

                Function min has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                export const min: Validation = function min(value, field, validation, time, params) {
                Severity: Minor
                Found in metatonic-core/src/services/BuiltInValidations.ts - About 35 mins to fix

                  Function max has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  export const max: Validation = function max(value, field, validation, time, params) {
                  Severity: Minor
                  Found in metatonic-core/src/services/BuiltInValidations.ts - About 35 mins to fix

                    Function getDefaultFormState has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function getDefaultFormState(type: SchemaType, value?) {
                        const addChildFieldStateForField:FieldStateAdder = (children, field) => Object.assign(children, {
                            [field.name]: field.multiple && value && value[field.name] && Array.isArray(value[field.name]) ?
                                {
                                    validationMessages:[],
                    Severity: Minor
                    Found in metatonic-core/src/services/DefaultFormState.ts - About 35 mins 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 compare has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function compare(left: DecimalData, right: DecimalData): number|null {
                        if (left === null || right === null) return null;
                        if (left.leftInt === right.leftInt) {
                            if (left.rightZeros === right.rightZeros) {
                                return left.rightInt - right.rightInt;
                    Severity: Minor
                    Found in metatonic-core/src/data/Decimal.ts - About 35 mins 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 encode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function encode(obj, prefix?) {
                        let str = new Array<any>(), prop;
                        for (prop in obj) {
                            if (obj.hasOwnProperty(prop)) {
                                let key = getQueryStringKeyForObjectProp(prefix, prop);
                    Severity: Minor
                    Found in metatonic-core/src/services/QueryStringEncoding.ts - About 35 mins 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 getEditorComponents has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        getEditorComponents(field: SchemaField): LabeledEditor<TEditor, TLabeler, TRepeater>|null {
                            if (!field.name && !field.entryType)
                                return this.edit.getEditorParts(field.typeName, field.uiControlPreference);
                    
                            if (field.entryType === SchemaEntryType.entry) {
                    Severity: Minor
                    Found in metatonic-core/src/services/EditorResolver.ts - About 35 mins 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

                    Avoid too many return statements within this function.
                    Open

                            if (dateTimeParams.type === DateTimeTypes.DateTime) return TimeStamp;
                    Severity: Major
                    Found in metatonic-core/src/services/DataTypeForField.ts - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language