tuplo/dynoexpr

View on GitHub

Showing 52 of 52 total issues

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

        it("update expression with if_not_exists", () => {
            const args = {
                Update: { foo: "if_not_exists(bar)" },
            };
            const actual = getUpdateExpression(args);
Severity: Major
Found in src/expressions/update.test.ts and 1 other location - About 2 hrs to fix
src/bug-reports.test.ts on lines 44..57

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

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

export function getUpdateExpression(params: IUpdateInput = {}) {
    if (!params.Update) return params;

    const { Update, UpdateAction = "SET", ...restOfParams } = params;
    const { ExpressionAttributeNames = {}, ExpressionAttributeValues = {} } =
Severity: Major
Found in src/expressions/update.ts - About 2 hrs to fix

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

            it("builds a condition expression", () => {
                const actual = buildConditionExpression({ Condition });
    
                const expected = [
                    "#na0f0d7ff = :v5f0025bb",
    Severity: Major
    Found in src/expressions/helpers.test.ts and 1 other location - About 2 hrs to fix
    src/expressions/helpers.test.ts on lines 328..344

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

    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

            it("builds a condition expression", () => {
                const actual = buildConditionExpression({ Condition });
    
                const expected = [
                    "attribute_exists(#na0f0d7ff)",
    Severity: Major
    Found in src/expressions/helpers.test.ts and 1 other location - About 2 hrs to fix
    src/expressions/helpers.test.ts on lines 161..177

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

    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

            it("builds the ExpressionAttributeNameMap", () => {
                const actual = buildConditionAttributeNames(Condition);
    
                const expected = {
                    "#na0f0d7ff": "a",
    Severity: Major
    Found in src/expressions/helpers.test.ts and 1 other location - About 2 hrs to fix
    src/expressions/helpers.test.ts on lines 346..360

    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

            it("builds the ExpressionAttributeNameMap", () => {
                const actual = buildConditionAttributeNames(Condition);
    
                const expected = {
                    "#na0f0d7ff": "a",
    Severity: Major
    Found in src/expressions/helpers.test.ts and 1 other location - About 2 hrs to fix
    src/expressions/helpers.test.ts on lines 234..248

    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

    Function buildConditionExpression has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function buildConditionExpression(args: IBuildConditionExpressionArgs) {
        const { Condition = {}, LogicalOperator = "AND" } = args;
    
        return flattenExpressions(Condition)
            .map(([key, value]) => {
    Severity: Minor
    Found in src/expressions/helpers.ts - About 1 hr to fix

      Function buildConditionAttributeValues has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function buildConditionAttributeValues(
          condition: Record<string, IDynoexprInputValue>,
          params: IConditionAttributeValuesParams = {}
      ) {
          return flattenExpressions(condition).reduce(
      Severity: Minor
      Found in src/expressions/helpers.ts - About 1 hr to fix

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

                        if (REGEX_COMPARISON.test(strValue)) {
                            const [, operator] = /([<=>]+)/.exec(strValue) || [];
                            const v = parseComparisonValue(strValue);
                            expr = `${getAttrName(key)} ${operator} ${getAttrValue(v)}`;
                        } else if (REGEX_BETWEEN.test(strValue)) {
        Severity: Major
        Found in src/expressions/helpers.ts and 1 other location - About 1 hr to fix
        src/expressions/helpers.ts on lines 131..137

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

        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 if (REGEX_SIZE.test(strValue)) {
                            const [, operator] = /([<=>]+)/.exec(strValue) || [];
                            const v = parseSizeValue(strValue);
                            expr = `size(${getAttrName(key)}) ${operator} ${getAttrValue(v)}`;
                        } else {
        Severity: Major
        Found in src/expressions/helpers.ts and 1 other location - About 1 hr to fix
        src/expressions/helpers.ts on lines 107..137

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

        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

            it.each([
                ['"foobar"', "foobar"],
                ['"foobar', "foobar"],
                ['foobar"', "foobar"],
            ])("unquote: %s", (input, expected) => {
        Severity: Major
        Found in src/utils.test.ts and 1 other location - About 1 hr to fix
        src/expressions/helpers.test.ts on lines 111..118

        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

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

                it.each([
                    ["not contains(foo)", "contains(foo)"],
                    ["not begins_with(foo)", "begins_with(foo)"],
                    ["not begins_with(1)", "begins_with(1)"],
                ])("parse not conditions: %s", (expr, expected) => {
        Severity: Major
        Found in src/expressions/helpers.test.ts and 1 other location - About 1 hr to fix
        src/utils.test.ts on lines 42..49

        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

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

        export function getUpdateRemoveExpression(params?: IUpdateInput) {
            const { UpdateRemove, ...restOfParams } = params || {};
        
            return getUpdateExpression({
                ...restOfParams,
        Severity: Major
        Found in src/expressions/update-ops.ts and 3 other locations - About 1 hr to fix
        src/expressions/update-ops.ts on lines 5..13
        src/expressions/update-ops.ts on lines 25..33
        src/expressions/update-ops.ts on lines 35..43

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

        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

        export function getUpdateSetExpression(params?: IUpdateInput) {
            const { UpdateSet, ...restOfParams } = params || {};
        
            return getUpdateExpression({
                ...restOfParams,
        Severity: Major
        Found in src/expressions/update-ops.ts and 3 other locations - About 1 hr to fix
        src/expressions/update-ops.ts on lines 15..23
        src/expressions/update-ops.ts on lines 25..33
        src/expressions/update-ops.ts on lines 35..43

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

        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

        export function getUpdateAddExpression(params?: IUpdateInput) {
            const { UpdateAdd, ...restOfParams } = params || {};
        
            return getUpdateExpression({
                ...restOfParams,
        Severity: Major
        Found in src/expressions/update-ops.ts and 3 other locations - About 1 hr to fix
        src/expressions/update-ops.ts on lines 5..13
        src/expressions/update-ops.ts on lines 15..23
        src/expressions/update-ops.ts on lines 35..43

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

        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

        export function getUpdateDeleteExpression(params?: IUpdateInput) {
            const { UpdateDelete, ...restOfParams } = params || {};
        
            return getUpdateExpression({
                ...restOfParams,
        Severity: Major
        Found in src/expressions/update-ops.ts and 3 other locations - About 1 hr to fix
        src/expressions/update-ops.ts on lines 5..13
        src/expressions/update-ops.ts on lines 15..23
        src/expressions/update-ops.ts on lines 25..33

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

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

        export function getExpressionAttributes(params: IUpdateInput) {
            const { Update = {}, UpdateAction = "SET" } = params;
        
            return Object.entries(Update).reduce((acc, [key, value]) => {
                if (!acc.ExpressionAttributeNames) acc.ExpressionAttributeNames = {};
        Severity: Minor
        Found in src/expressions/update.ts - About 1 hr to fix

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

                  const args = {
                      UpdateAdd: {
                          foo: "bar",
                          baz: 2,
                          bez: [1, 2, 3],
          Severity: Major
          Found in src/expressions/update-ops.test.ts and 1 other location - About 1 hr to fix
          src/expressions/update-ops.test.ts on lines 104..112

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

          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 args = {
                      UpdateDelete: {
                          foo: "bar",
                          baz: 2,
                          bez: [1, 2, 3],
          Severity: Major
          Found in src/expressions/update-ops.test.ts and 1 other location - About 1 hr to fix
          src/expressions/update-ops.test.ts on lines 71..79

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

          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

                  it.each(["> 5", ">5", ">  5", ">=5", ">= 5", ">=  5"])(
                      "comparison v: %s",
                      (expr) => {
                          const actual = parseComparisonValue(expr);
                          expect(actual).toBe(5);
          Severity: Major
          Found in src/expressions/helpers.test.ts and 1 other location - About 1 hr to fix
          src/expressions/helpers.test.ts on lines 99..109

          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

          Severity
          Category
          Status
          Source
          Language