OpenHPS/openhps-rdf

View on GitHub
src/rdf/InternalRDFSerializer.ts

Summary

Maintainability
F
4 days
Test Coverage

Function serializeObject has 128 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    serializeObject<T, TD extends TypeDescriptor>(
        sourceObject: T,
        typeDescriptor: TD,
        _: string,
        serializer: Serializer,
Severity: Major
Found in src/rdf/InternalRDFSerializer.ts - About 5 hrs to fix

    Function serializeObject has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        serializeObject<T, TD extends TypeDescriptor>(
            sourceObject: T,
            typeDescriptor: TD,
            _: string,
            serializer: Serializer,
    Severity: Minor
    Found in src/rdf/InternalRDFSerializer.ts - About 4 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

    File InternalRDFSerializer.ts has 345 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import {
        ArrayTypeDescriptor,
        MapTypeDescriptor,
        ObjectMemberMetadata,
        ObjectMetadata,
    Severity: Minor
    Found in src/rdf/InternalRDFSerializer.ts - About 4 hrs to fix

      Function convertSingleValue has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          convertSingleValue(
              sourceObject: any,
              typeDescriptor: TypeDescriptor,
              memberName: string,
              memberOptions?: ObjectMemberMetadata,
      Severity: Major
      Found in src/rdf/InternalRDFSerializer.ts - About 2 hrs to fix

        Function convertSingleValue has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            convertSingleValue(
                sourceObject: any,
                typeDescriptor: TypeDescriptor,
                memberName: string,
                memberOptions?: ObjectMemberMetadata,
        Severity: Minor
        Found in src/rdf/InternalRDFSerializer.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 serializeLiteral has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            protected serializeLiteral(
                sourceObject: any,
                typeDescriptor?: TypeDescriptor,
                memberName?: string,
                serializer?: Serializer,
        Severity: Minor
        Found in src/rdf/InternalRDFSerializer.ts - About 55 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

                        return mergeDeep(
                            {
                                termType: 'BlankNode',
                                value: this.blankNode(undefined, serializerOptions).value,
                                predicates: {},
        Severity: Major
        Found in src/rdf/InternalRDFSerializer.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                          return output as NamedNode;
          Severity: Major
          Found in src/rdf/InternalRDFSerializer.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return serializer(sourceObject, typeDescriptor, memberName, this, memberOptions, serializerOptions);
            Severity: Major
            Found in src/rdf/InternalRDFSerializer.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return this.serializeObject(
                              sourceObject,
                              typeDescriptor,
                              memberName,
                              this,
              Severity: Major
              Found in src/rdf/InternalRDFSerializer.ts - About 30 mins to fix

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

                    serializationStrategy = new Map<Serializable<any>, SerializerFn<any, TypeDescriptor, any>>([
                        [Number, this.serializeLiteral.bind(this)],
                        [String, this.serializeLiteral.bind(this)],
                        [Boolean, this.serializeLiteral.bind(this)],
                        [Date, this.serializeDate.bind(this)],
                Severity: Major
                Found in src/rdf/InternalRDFSerializer.ts and 1 other location - About 5 hrs to fix
                src/rdf/InternalRDFDeserializer.ts on lines 20..28

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

                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 identifierMember = Array.from(metadata.dataMembers.values()).filter((member) => {
                            return (
                                member &&
                                member.options &&
                                member.options.rdf &&
                Severity: Major
                Found in src/rdf/InternalRDFSerializer.ts and 1 other location - About 2 hrs to fix
                src/rdf/InternalRDFDeserializer.ts on lines 192..199

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

                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 (
                                    !memberOptions ||
                                    (!(memberOptions.options.rdf as RDFLiteralOptions).predicate &&
                                        !memberOptions.options.rdf.serializer) ||
                                    memberOptions.options.rdf.identifier
                Severity: Major
                Found in src/rdf/InternalRDFSerializer.ts and 1 other location - About 1 hr to fix
                src/rdf/InternalRDFDeserializer.ts on lines 230..237

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

                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

                    protected serializeSet(
                        sourceObject: Map<any, any>,
                        typeDescriptor?: MapTypeDescriptor,
                        memberName?: string,
                        _?: Serializer,
                Severity: Major
                Found in src/rdf/InternalRDFSerializer.ts and 1 other location - About 1 hr to fix
                src/rdf/InternalRDFSerializer.ts on lines 291..302

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

                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

                                const memberOptions =
                                    member.options && member.options.rdf
                                        ? member
                                        : rootMember && rootMember.options && rootMember.options.rdf
                                          ? rootMember
                Severity: Major
                Found in src/rdf/InternalRDFSerializer.ts and 1 other location - About 1 hr to fix
                src/rdf/InternalRDFDeserializer.ts on lines 223..228

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

                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

                    protected serializeMap(
                        sourceObject: Map<any, any>,
                        typeDescriptor?: MapTypeDescriptor,
                        memberName?: string,
                        _?: Serializer,
                Severity: Major
                Found in src/rdf/InternalRDFSerializer.ts and 1 other location - About 1 hr to fix
                src/rdf/InternalRDFSerializer.ts on lines 304..315

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

                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