asteris-llc/converge

View on GitHub
resource/preparer_test.go

Summary

Maintainability
D
2 days
Test Coverage

Function TestPreparerPrepare has 306 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func TestPreparerPrepare(t *testing.T) {
    defer logging.HideLogs(t)()

    // newWithField is a little utility. We have this pattern over and over
    // where we need to set a target field and then check that we render without
Severity: Major
Found in resource/preparer_test.go - About 1 day to fix

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

                t.Run("short form", func(t *testing.T) {
                    val := "2003-01-"
                    prep := &resource.Preparer{
                        Source:      map[string]interface{}{"time": val},
                        Destination: new(testPreparerTarget),
    Severity: Major
    Found in resource/preparer_test.go and 3 other locations - About 1 hr to fix
    resource/preparer_test.go on lines 175..188
    resource/preparer_test.go on lines 205..218
    resource/preparer_test.go on lines 220..233

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

    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

                t.Run("zone provided-extra text", func(t *testing.T) {
                    val := "2003-01-02T01:02:03-25:00:00"
                    prep := &resource.Preparer{
                        Source:      map[string]interface{}{"time": val},
                        Destination: new(testPreparerTarget),
    Severity: Major
    Found in resource/preparer_test.go and 3 other locations - About 1 hr to fix
    resource/preparer_test.go on lines 175..188
    resource/preparer_test.go on lines 190..203
    resource/preparer_test.go on lines 205..218

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

    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

                t.Run("long form-second out of range", func(t *testing.T) {
                    val := "2003-01-02T01:02:61"
                    prep := &resource.Preparer{
                        Source:      map[string]interface{}{"time": val},
                        Destination: new(testPreparerTarget),
    Severity: Major
    Found in resource/preparer_test.go and 3 other locations - About 1 hr to fix
    resource/preparer_test.go on lines 175..188
    resource/preparer_test.go on lines 190..203
    resource/preparer_test.go on lines 220..233

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

    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

                t.Run("unknown", func(t *testing.T) {
                    val := "3.2"
                    prep := &resource.Preparer{
                        Source:      map[string]interface{}{"time": val},
                        Destination: new(testPreparerTarget),
    Severity: Major
    Found in resource/preparer_test.go and 3 other locations - About 1 hr to fix
    resource/preparer_test.go on lines 190..203
    resource/preparer_test.go on lines 205..218
    resource/preparer_test.go on lines 220..233

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

    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

            t.Run("invalid", func(t *testing.T) {
                prep := &resource.Preparer{
                    Source:      map[string]interface{}{"valid_values": "invalid"},
                    Destination: new(testPreparerTarget),
                }
    Severity: Minor
    Found in resource/preparer_test.go and 1 other location - About 45 mins to fix
    resource/preparer_test.go on lines 403..411

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

    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

            t.Run("invalid", func(t *testing.T) {
                prep := &resource.Preparer{
                    Source:      map[string]interface{}{"nonempty": ""},
                    Destination: new(testNonemptyTarget),
                }
    Severity: Minor
    Found in resource/preparer_test.go and 1 other location - About 45 mins to fix
    resource/preparer_test.go on lines 351..359

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

    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

            t.Run("valid", func(t *testing.T) {
                prep := &resource.Preparer{
                    Source:      map[string]interface{}{"nonempty": "a"},
                    Destination: new(testNonemptyTarget),
                }
    Severity: Minor
    Found in resource/preparer_test.go and 1 other location - About 40 mins to fix
    resource/preparer_test.go on lines 370..378

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

    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

            t.Run("valid", func(t *testing.T) {
                prep := &resource.Preparer{
                    Source:      map[string]interface{}{"required": "a"},
                    Destination: new(testRequiredTarget),
                }
    Severity: Minor
    Found in resource/preparer_test.go and 1 other location - About 40 mins to fix
    resource/preparer_test.go on lines 393..401

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

    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

            t.Run("short form", func(t *testing.T) {
                val := "2003-01-02"
                expected, err := time.ParseInLocation(shortForm, val, zone)
                require.NoError(t, err)
                target := newWithField(t, "time", val)
    Severity: Minor
    Found in resource/preparer_test.go and 1 other location - About 35 mins to fix
    resource/preparer_test.go on lines 158..164

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

    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

            t.Run("long form", func(t *testing.T) {
                val := "2003-01-02T01:02:03"
                expected, err := time.ParseInLocation(longForm, val, zone)
                require.NoError(t, err)
                target := newWithField(t, "time", val)
    Severity: Minor
    Found in resource/preparer_test.go and 1 other location - About 35 mins to fix
    resource/preparer_test.go on lines 150..156

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

    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

    error strings should not be capitalized or end with punctuation or a newline
    Open

                    expectedErr := fmt.Errorf("could not convert time to time.Time any of:\n1. %v\n2. %v\n3. %v\n", ztErr, ltErr, stErr)
    Severity: Minor
    Found in resource/preparer_test.go by golint

    error strings should not be capitalized or end with punctuation or a newline
    Open

                    expectedErr := fmt.Errorf("could not convert time to time.Time any of:\n1. %v\n2. %v\n3. %v\n", ztErr, ltErr, stErr)
    Severity: Minor
    Found in resource/preparer_test.go by golint

    error strings should not be capitalized or end with punctuation or a newline
    Open

                    expectedErr := fmt.Errorf("could not convert time to time.Time any of:\n1. %v\n2. %v\n3. %v\n", ztErr, ltErr, stErr)
    Severity: Minor
    Found in resource/preparer_test.go by golint

    error strings should not be capitalized or end with punctuation or a newline
    Open

                    expectedErr := fmt.Errorf("could not convert time to time.Time any of:\n1. %v\n2. %v\n3. %v\n", ztErr, ltErr, stErr)
    Severity: Minor
    Found in resource/preparer_test.go by golint

    There are no issues that match your filters.

    Category
    Status