Bnei-Baruch/mdb

View on GitHub
api/handlers_test.go

Summary

Maintainability
F
1 wk
Test Coverage

File handlers_test.go has 1583 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package api

import (
    "database/sql"
    "encoding/hex"
Severity: Major
Found in api/handlers_test.go - About 3 days to fix

    Method HandlersSuite.TestHandleConvert has 158 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (suite *HandlersSuite) TestHandleConvert() {
        // Create dummy input file
        fi := File{
            FileName:  "dummy input file",
            CreatedAt: &Timestamp{time.Now()},
    Severity: Major
    Found in api/handlers_test.go - About 5 hrs to fix

      Method HandlersSuite.TestHandleTranscodeSuccess has 100 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (suite *HandlersSuite) TestHandleTranscodeSuccess() {
          // Create dummy original file
          ofi := File{
              FileName:  "dummy_original_file.wmv",
              CreatedAt: &Timestamp{time.Now()},
      Severity: Major
      Found in api/handlers_test.go - About 3 hrs to fix

        HandlersSuite has 25 methods (exceeds 20 allowed). Consider refactoring.
        Open

        type HandlersSuite struct {
            suite.Suite
            utils.TestDBManager
            tx *sql.Tx
        }
        Severity: Minor
        Found in api/handlers_test.go - About 2 hrs to fix

          Method HandlersSuite.TestHandleInsertKiteiMakor has 95 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (suite *HandlersSuite) TestHandleInsertKiteiMakor() {
              // Create dummy content unit
              cu, err := CreateContentUnit(suite.tx, common.CT_LESSON_PART, nil)
              suite.Require().Nil(err)
          
          
          Severity: Major
          Found in api/handlers_test.go - About 2 hrs to fix

            Method HandlersSuite.TestHandleUpload has 92 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (suite *HandlersSuite) TestHandleUpload() {
                // First seen, unknown, file
                input := UploadRequest{
                    Operation: Operation{
                        Station: "Upload station",
            Severity: Major
            Found in api/handlers_test.go - About 2 hrs to fix

              Method HandlersSuite.TestHandleInsertPublication has 91 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (suite *HandlersSuite) TestHandleInsertPublication() {
                  // Create dummy content unit
                  cu, err := CreateContentUnit(suite.tx, common.CT_ARTICLE, nil)
                  suite.Require().Nil(err)
              
              
              Severity: Major
              Found in api/handlers_test.go - About 2 hrs to fix

                Method HandlersSuite.TestHandleTrim has 88 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (suite *HandlersSuite) TestHandleTrim() {
                    // Create dummy original and proxy parent files
                    ofi := File{
                        FileName:  "dummy original parent file",
                        CreatedAt: &Timestamp{time.Now()},
                Severity: Major
                Found in api/handlers_test.go - About 2 hrs to fix

                  Method HandlersSuite.TestHandleJoin has 88 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (suite *HandlersSuite) TestHandleJoin() {
                      // create dummy input files
                  
                      inOriginals := make([]string, 3)
                      for i := 0; i < len(inOriginals); i++ {
                  Severity: Major
                  Found in api/handlers_test.go - About 2 hrs to fix

                    Method HandlersSuite.TestHandleInsert has 84 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (suite *HandlersSuite) TestHandleInsert() {
                        // Create dummy content unit
                        cu, err := CreateContentUnit(suite.tx, common.CT_LESSON_PART, nil)
                        suite.Require().Nil(err)
                    
                    
                    Severity: Major
                    Found in api/handlers_test.go - About 2 hrs to fix

                      Method HandlersSuite.TestHandleDemux has 70 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (suite *HandlersSuite) TestHandleDemux() {
                          // Create dummy parent file
                          fi := File{
                              FileName:  "dummy parent file",
                              CreatedAt: &Timestamp{time.Now()},
                      Severity: Minor
                      Found in api/handlers_test.go - About 1 hr to fix

                        Method HandlersSuite.TestHandleInsertUpdateMode has 68 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (suite *HandlersSuite) TestHandleInsertUpdateMode() {
                            // Create dummy content unit
                            cu, err := CreateContentUnit(suite.tx, common.CT_LESSON_PART, nil)
                            suite.Require().Nil(err)
                        
                        
                        Severity: Minor
                        Found in api/handlers_test.go - About 1 hr to fix

                          Method HandlersSuite.TestHandleInsertRenameMode has 68 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func (suite *HandlersSuite) TestHandleInsertRenameMode() {
                              // Create dummy content unit
                              cu, err := CreateContentUnit(suite.tx, common.CT_LESSON_PART, nil)
                              suite.Require().Nil(err)
                          
                          
                          Severity: Minor
                          Found in api/handlers_test.go - About 1 hr to fix

                            Method HandlersSuite.TestHandleInsertDeclamation has 64 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func (suite *HandlersSuite) TestHandleInsertDeclamation() {
                                // Do insert operation
                                input := InsertRequest{
                                    Operation: Operation{
                                        Station:    "Some station",
                            Severity: Minor
                            Found in api/handlers_test.go - About 1 hr to fix

                              Method HandlersSuite.TestHandleTrimNoProxy has 60 lines of code (exceeds 50 allowed). Consider refactoring.
                              Open

                              func (suite *HandlersSuite) TestHandleTrimNoProxy() {
                                  // Create dummy original parent file
                                  ofi := File{
                                      FileName:  "dummy original parent file",
                                      CreatedAt: &Timestamp{time.Now()},
                              Severity: Minor
                              Found in api/handlers_test.go - About 1 hr to fix

                                Method HandlersSuite.TestHandleCaptureStop has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                                Open

                                func (suite *HandlersSuite) TestHandleCaptureStop() {
                                    // Prepare capture_start operation
                                    opStart, evnts, err := handleCaptureStart(suite.tx, CaptureStartRequest{
                                        Operation: Operation{
                                            Station:    "Capture station",
                                Severity: Minor
                                Found in api/handlers_test.go - About 1 hr to fix

                                  Method HandlersSuite.TestHandleSend has 57 lines of code (exceeds 50 allowed). Consider refactoring.
                                  Open

                                  func (suite *HandlersSuite) TestHandleSend() {
                                      // Create dummy original and proxy trimmed files
                                      ofi := File{
                                          FileName:  "dummy original trimmed file",
                                          CreatedAt: &Timestamp{time.Now()},
                                  Severity: Minor
                                  Found in api/handlers_test.go - About 1 hr to fix

                                    Method HandlersSuite.TestHandleJoinNoProxy has 56 lines of code (exceeds 50 allowed). Consider refactoring.
                                    Open

                                    func (suite *HandlersSuite) TestHandleJoinNoProxy() {
                                        // create dummy input files
                                    
                                        inOriginals := make([]string, 3)
                                        for i := 0; i < len(inOriginals); i++ {
                                    Severity: Minor
                                    Found in api/handlers_test.go - About 1 hr to fix

                                      Method HandlersSuite.TestHandleDemuxNoProxy has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                                      Open

                                      func (suite *HandlersSuite) TestHandleDemuxNoProxy() {
                                          // Create dummy parent file
                                          fi := File{
                                              FileName:  "dummy parent file",
                                              CreatedAt: &Timestamp{time.Now()},
                                      Severity: Minor
                                      Found in api/handlers_test.go - About 1 hr to fix

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

                                            for i, x := range input.Output {
                                                f := fm[x.FileName]
                                                suite.Equal(x.FileName, f.Name, "Output[%d]: Name", i)
                                                suite.Equal(x.Sha1, hex.EncodeToString(f.Sha1.Bytes), "Output[%d]: SHA1", i)
                                                suite.Equal(x.Size, f.Size, "Output[%d]: Size", i)
                                        Severity: Major
                                        Found in api/handlers_test.go and 1 other location - About 4 hrs to fix
                                        api/handlers_test.go on lines 747..761

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

                                        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

                                            for i, x := range input.Output[:len(input.Output)-2] {
                                                f := fm[x.FileName]
                                                suite.Equal(x.FileName, f.Name, "Output[%d]: Name", i)
                                                suite.Equal(x.Sha1, hex.EncodeToString(f.Sha1.Bytes), "Output[%d]: SHA1", i)
                                                suite.Equal(x.Size, f.Size, "Output[%d]: Size", i)
                                        Severity: Major
                                        Found in api/handlers_test.go and 1 other location - About 4 hrs to fix
                                        api/handlers_test.go on lines 804..818

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

                                        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 3 locations. Consider refactoring.
                                        Open

                                            for i := 0; i < len(inOriginals); i++ {
                                                fi := File{
                                                    FileName:  fmt.Sprintf("dummy original file %d", i+1),
                                                    CreatedAt: &Timestamp{time.Now()},
                                                    Sha1:      utils.RandomSHA1(),
                                        Severity: Major
                                        Found in api/handlers_test.go and 2 other locations - About 1 hr to fix
                                        api/handlers_test.go on lines 1810..1820
                                        api/handlers_test.go on lines 1904..1914

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

                                        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 3 locations. Consider refactoring.
                                        Open

                                            for i := 0; i < len(inOriginals); i++ {
                                                fi := File{
                                                    FileName:  fmt.Sprintf("dummy original file %d", i+1),
                                                    CreatedAt: &Timestamp{time.Now()},
                                                    Sha1:      utils.RandomSHA1(),
                                        Severity: Major
                                        Found in api/handlers_test.go and 2 other locations - About 1 hr to fix
                                        api/handlers_test.go on lines 1797..1807
                                        api/handlers_test.go on lines 1810..1820

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

                                        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 3 locations. Consider refactoring.
                                        Open

                                            for i := 0; i < len(inProxies); i++ {
                                                fi := File{
                                                    FileName:  fmt.Sprintf("dummy proxy file %d", i+1),
                                                    CreatedAt: &Timestamp{time.Now()},
                                                    Sha1:      utils.RandomSHA1(),
                                        Severity: Major
                                        Found in api/handlers_test.go and 2 other locations - About 1 hr to fix
                                        api/handlers_test.go on lines 1797..1807
                                        api/handlers_test.go on lines 1904..1914

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

                                        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

                                            input := InsertRequest{
                                                Operation: Operation{
                                                    Station:    "Some station",
                                                    User:       "operator@dev.com",
                                                    WorkflowID: "workflow_id",
                                        Severity: Minor
                                        Found in api/handlers_test.go and 1 other location - About 50 mins to fix
                                        api/handlers_test.go on lines 1009..1029

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

                                        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

                                            input := InsertRequest{
                                                Operation: Operation{
                                                    Station:    "Some station",
                                                    User:       "operator@dev.com",
                                                    WorkflowID: "workflow_id",
                                        Severity: Minor
                                        Found in api/handlers_test.go and 1 other location - About 50 mins to fix
                                        api/handlers_test.go on lines 1554..1574

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

                                        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