Bnei-Baruch/mdb

View on GitHub
api/repo.go

Summary

Maintainability
F
3 days
Test Coverage

File repo.go has 710 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package api

import (
    "database/sql"
    "encoding/hex"
Severity: Minor
Found in api/repo.go - About 7 hrs to fix

    Function FileLeftUnitImpact has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
    Open

    func FileLeftUnitImpact(exec boil.Executor, fileIsPublished bool, cuID int64) (*PublishedChangeImpact, error) {
        impact := new(PublishedChangeImpact)
    
        if !fileIsPublished {
            return impact, nil
    Severity: Minor
    Found in api/repo.go - About 3 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function FileLeftUnitImpact has 66 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func FileLeftUnitImpact(exec boil.Executor, fileIsPublished bool, cuID int64) (*PublishedChangeImpact, error) {
        impact := new(PublishedChangeImpact)
    
        if !fileIsPublished {
            return impact, nil
    Severity: Minor
    Found in api/repo.go - About 1 hr to fix

      Function FileLeftUnitImpact has 8 return statements (exceeds 4 allowed).
      Open

      func FileLeftUnitImpact(exec boil.Executor, fileIsPublished bool, cuID int64) (*PublishedChangeImpact, error) {
          impact := new(PublishedChangeImpact)
      
          if !fileIsPublished {
              return impact, nil
      Severity: Major
      Found in api/repo.go - About 50 mins to fix

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

        func UpdateFile(exec boil.Executor, obj *models.File, parent *models.File, f File, properties map[string]interface{}) error {
        Severity: Minor
        Found in api/repo.go - About 35 mins to fix

          Function UpdateFileProperties has 5 return statements (exceeds 4 allowed).
          Open

          func UpdateFileProperties(exec boil.Executor, file *models.File, props map[string]interface{}) error {
              if len(props) == 0 {
                  return nil
              }
          
          
          Severity: Major
          Found in api/repo.go - About 35 mins to fix

            Function CreateCollection has 5 return statements (exceeds 4 allowed).
            Open

            func CreateCollection(exec boil.Executor, contentType string, properties map[string]interface{}) (*models.Collection, error) {
                ct, ok := common.CONTENT_TYPE_REGISTRY.ByName[contentType]
                if !ok {
                    return nil, errors.Errorf("Unknown content type %s", contentType)
                }
            Severity: Major
            Found in api/repo.go - About 35 mins to fix

              Function CreateContentUnit has 5 return statements (exceeds 4 allowed).
              Open

              func CreateContentUnit(exec boil.Executor, contentType string, properties map[string]interface{}) (*models.ContentUnit, error) {
                  ct, ok := common.CONTENT_TYPE_REGISTRY.ByName[contentType]
                  if !ok {
                      return nil, errors.Errorf("Unknown content type %s", contentType)
                  }
              Severity: Major
              Found in api/repo.go - About 35 mins to fix

                Function FileAddedUnitImpact has 5 return statements (exceeds 4 allowed).
                Open

                func FileAddedUnitImpact(exec boil.Executor, fileIsPublished bool, cuID int64) (*PublishedChangeImpact, error) {
                    impact := new(PublishedChangeImpact)
                
                    if !fileIsPublished {
                        return impact, nil
                Severity: Major
                Found in api/repo.go - About 35 mins to fix

                  Function UpdateContentUnitProperties has 5 return statements (exceeds 4 allowed).
                  Open

                  func UpdateContentUnitProperties(exec boil.Executor, unit *models.ContentUnit, props map[string]interface{}) error {
                      if len(props) == 0 {
                          return nil
                      }
                  
                  
                  Severity: Major
                  Found in api/repo.go - About 35 mins to fix

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

                    func UpdateFileProperties(exec boil.Executor, file *models.File, props map[string]interface{}) error {
                        if len(props) == 0 {
                            return nil
                        }
                    
                    
                    Severity: Major
                    Found in api/repo.go and 1 other location - About 3 hrs to fix
                    api/repo.go on lines 344..374

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

                    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

                    func UpdateContentUnitProperties(exec boil.Executor, unit *models.ContentUnit, props map[string]interface{}) error {
                        if len(props) == 0 {
                            return nil
                        }
                    
                    
                    Severity: Major
                    Found in api/repo.go and 1 other location - About 3 hrs to fix
                    api/repo.go on lines 479..509

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

                    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

                    func CreateCollection(exec boil.Executor, contentType string, properties map[string]interface{}) (*models.Collection, error) {
                        ct, ok := common.CONTENT_TYPE_REGISTRY.ByName[contentType]
                        if !ok {
                            return nil, errors.Errorf("Unknown content type %s", contentType)
                        }
                    Severity: Major
                    Found in api/repo.go and 1 other location - About 3 hrs to fix
                    api/repo.go on lines 282..312

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

                    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

                    func CreateContentUnit(exec boil.Executor, contentType string, properties map[string]interface{}) (*models.ContentUnit, error) {
                        ct, ok := common.CONTENT_TYPE_REGISTRY.ByName[contentType]
                        if !ok {
                            return nil, errors.Errorf("Unknown content type %s", contentType)
                        }
                    Severity: Major
                    Found in api/repo.go and 1 other location - About 3 hrs to fix
                    api/repo.go on lines 200..230

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

                    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

                    func FindTagPath(exec boil.Executor, id int64) ([]*models.Tag, error) {
                        var ancestors []*models.Tag
                    
                        err := queries.Raw(TAG_PATH_SQL, id).Bind(nil, exec, &ancestors)
                        if err != nil {
                    Severity: Major
                    Found in api/repo.go and 3 other locations - About 40 mins to fix
                    api/repo.go on lines 709..718
                    api/repo.go on lines 720..729
                    api/repo.go on lines 765..774

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

                    func FindFileDescendants(exec boil.Executor, id int64) ([]*models.File, error) {
                        var descendants []*models.File
                    
                        err := queries.Raw(FILE_DESCENDANTS_SQL, id).Bind(nil, exec, &descendants)
                        if err != nil {
                    Severity: Major
                    Found in api/repo.go and 3 other locations - About 40 mins to fix
                    api/repo.go on lines 709..718
                    api/repo.go on lines 765..774
                    api/repo.go on lines 787..796

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

                    func FindFileAncestors(exec boil.Executor, id int64) ([]*models.File, error) {
                        var ancestors []*models.File
                    
                        err := queries.Raw(FILE_ANCESTORS_SQL, id).Bind(nil, exec, &ancestors)
                        if err != nil {
                    Severity: Major
                    Found in api/repo.go and 3 other locations - About 40 mins to fix
                    api/repo.go on lines 720..729
                    api/repo.go on lines 765..774
                    api/repo.go on lines 787..796

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

                    func FindSourcePath(exec boil.Executor, id int64) ([]*models.Source, error) {
                        var ancestors []*models.Source
                    
                        err := queries.Raw(SOURCE_PATH_SQL, id).Bind(nil, exec, &ancestors)
                        if err != nil {
                    Severity: Major
                    Found in api/repo.go and 3 other locations - About 40 mins to fix
                    api/repo.go on lines 709..718
                    api/repo.go on lines 720..729
                    api/repo.go on lines 787..796

                    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

                    There are no issues that match your filters.

                    Category
                    Status