Bnei-Baruch/mdb

View on GitHub
api/rest.go

Summary

Maintainability
F
1 mo
Test Coverage

File rest.go has 4166 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package api

import (
    "database/sql"
    "encoding/hex"
Severity: Major
Found in api/rest.go - About 1 wk to fix

    Function handleContentUnitsList has 88 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func handleContentUnitsList(cp utils.ContextProvider, exec boil.Executor, r ContentUnitsRequest) (*ContentUnitsResponse, *HttpError) {
        mods := make([]qm.QueryMod, 0)
        appendPermissionsMods(cp, &mods)
    
        // filters
    Severity: Major
    Found in api/rest.go - About 2 hrs to fix

      Function handleContentUnitsList has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
      Open

      func handleContentUnitsList(cp utils.ContextProvider, exec boil.Executor, r ContentUnitsRequest) (*ContentUnitsResponse, *HttpError) {
          mods := make([]qm.QueryMod, 0)
          appendPermissionsMods(cp, &mods)
      
          // filters
      Severity: Minor
      Found in api/rest.go - About 2 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 handleContentUnitMerge has 74 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func handleContentUnitMerge(cp utils.ContextProvider, exec boil.Executor, id int64, cuIDs []int64) (*ContentUnit, []events.Event, *HttpError) {
          unit, err := models.FindContentUnit(exec, id)
          if err != nil {
              if err == sql.ErrNoRows {
                  return nil, nil, NewNotFoundError()
      Severity: Minor
      Found in api/rest.go - About 1 hr to fix

        Function appendSearchTermFilterMods has 69 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func appendSearchTermFilterMods(exec boil.Executor, mods *[]qm.QueryMod, f SearchTermFilter, entityType int) error {
            if f.Query == "" {
                return nil
            }
        
        
        Severity: Minor
        Found in api/rest.go - About 1 hr to fix

          Function handleContentUnitMerge has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
          Open

          func handleContentUnitMerge(cp utils.ContextProvider, exec boil.Executor, id int64, cuIDs []int64) (*ContentUnit, []events.Event, *HttpError) {
              unit, err := models.FindContentUnit(exec, id)
              if err != nil {
                  if err == sql.ErrNoRows {
                      return nil, nil, NewNotFoundError()
          Severity: Minor
          Found in api/rest.go - About 1 hr to fix

          Cognitive Complexity

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

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

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

          Further reading

          Function handleUpdateContentUnit has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
          Open

          func handleUpdateContentUnit(cp utils.ContextProvider, exec boil.Executor, cu *PartialContentUnit) (*ContentUnit, *HttpError) {
              unit, err := models.FindContentUnit(exec, cu.ID)
              if err != nil {
                  if err == sql.ErrNoRows {
                      return nil, NewNotFoundError()
          Severity: Minor
          Found in api/rest.go - About 1 hr to fix

          Cognitive Complexity

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

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

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

          Further reading

          Function SourcesHandler has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
          Open

          func SourcesHandler(c *gin.Context) {
              var err *HttpError
              var resp interface{}
          
              if c.Request.Method == http.MethodGet || c.Request.Method == "" {
          Severity: Minor
          Found in api/rest.go - About 1 hr to fix

          Cognitive Complexity

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

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

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

          Further reading

          Function handleCreateSource has 64 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func handleCreateSource(exec boil.Executor, r CreateSourceRequest) (*Source, *HttpError) {
              s := r.Source
          
              // check pattern unique constraint
              if s.Pattern.Valid {
          Severity: Minor
          Found in api/rest.go - About 1 hr to fix

            Function handleContentUnitAddFiles has 61 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func handleContentUnitAddFiles(cp utils.ContextProvider, exec boil.Executor, id int64, fileIDs []int64) (*ContentUnit, []events.Event, *HttpError) {
                unit, err := models.FindContentUnit(exec, id)
                if err != nil {
                    if err == sql.ErrNoRows {
                        return nil, nil, NewNotFoundError()
            Severity: Minor
            Found in api/rest.go - About 1 hr to fix

              Function appendSearchTermFilterMods has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
              Open

              func appendSearchTermFilterMods(exec boil.Executor, mods *[]qm.QueryMod, f SearchTermFilter, entityType int) error {
                  if f.Query == "" {
                      return nil
                  }
              
              
              Severity: Minor
              Found in api/rest.go - About 1 hr to fix

              Cognitive Complexity

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

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

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

              Further reading

              Function handleContentUnitsList has 13 return statements (exceeds 4 allowed).
              Open

              func handleContentUnitsList(cp utils.ContextProvider, exec boil.Executor, r ContentUnitsRequest) (*ContentUnitsResponse, *HttpError) {
                  mods := make([]qm.QueryMod, 0)
                  appendPermissionsMods(cp, &mods)
              
                  // filters
              Severity: Major
              Found in api/rest.go - About 1 hr to fix

                Function handleUpdateFile has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func handleUpdateFile(cp utils.ContextProvider, exec boil.Executor, f *PartialFile) (*MFile, []events.Event, *HttpError) {
                    file, err := models.FindFile(exec, f.ID)
                    if err != nil {
                        if err == sql.ErrNoRows {
                            return nil, nil, NewNotFoundError()
                Severity: Minor
                Found in api/rest.go - About 1 hr to fix

                  Function CollectionContentUnitsHandler has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func CollectionContentUnitsHandler(c *gin.Context) {
                      id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                      if e != nil {
                          NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                          return
                  Severity: Minor
                  Found in api/rest.go - About 1 hr to fix

                    Function handleContentUnitAddPerson has 12 return statements (exceeds 4 allowed).
                    Open

                    func handleContentUnitAddPerson(cp utils.ContextProvider, exec boil.Executor, id int64, cup models.ContentUnitsPerson) (*models.ContentUnit, *HttpError) {
                        cu, err := models.FindContentUnit(exec, id)
                        if err != nil {
                            if err == sql.ErrNoRows {
                                return nil, NewNotFoundError()
                    Severity: Major
                    Found in api/rest.go - About 1 hr to fix

                      Function handleContentUnitMerge has 12 return statements (exceeds 4 allowed).
                      Open

                      func handleContentUnitMerge(cp utils.ContextProvider, exec boil.Executor, id int64, cuIDs []int64) (*ContentUnit, []events.Event, *HttpError) {
                          unit, err := models.FindContentUnit(exec, id)
                          if err != nil {
                              if err == sql.ErrNoRows {
                                  return nil, nil, NewNotFoundError()
                      Severity: Major
                      Found in api/rest.go - About 1 hr to fix

                        Function handleCreateSource has 12 return statements (exceeds 4 allowed).
                        Open

                        func handleCreateSource(exec boil.Executor, r CreateSourceRequest) (*Source, *HttpError) {
                            s := r.Source
                        
                            // check pattern unique constraint
                            if s.Pattern.Valid {
                        Severity: Major
                        Found in api/rest.go - About 1 hr to fix

                          Function handleCollectionCCU has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func handleCollectionCCU(cp utils.ContextProvider, exec boil.Executor, id int64) ([]*CollectionContentUnit, *HttpError) {
                              collection, err := models.FindCollection(exec, id)
                              if err != nil {
                                  if err == sql.ErrNoRows {
                                      return nil, NewNotFoundError()
                          Severity: Minor
                          Found in api/rest.go - About 1 hr to fix

                            Function handleUpdateContentUnit has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                            Open

                            func handleUpdateContentUnit(cp utils.ContextProvider, exec boil.Executor, cu *PartialContentUnit) (*ContentUnit, *HttpError) {
                                unit, err := models.FindContentUnit(exec, cu.ID)
                                if err != nil {
                                    if err == sql.ErrNoRows {
                                        return nil, NewNotFoundError()
                            Severity: Minor
                            Found in api/rest.go - About 1 hr to fix

                              Function handleCollectionsList has 11 return statements (exceeds 4 allowed).
                              Open

                              func handleCollectionsList(cp utils.ContextProvider, exec boil.Executor, r CollectionsRequest) (*CollectionsResponse, *HttpError) {
                                  mods := make([]qm.QueryMod, 0)
                                  appendPermissionsMods(cp, &mods)
                              
                                  // filters
                              Severity: Major
                              Found in api/rest.go - About 1 hr to fix

                                Function TagsHandler has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
                                Open

                                func TagsHandler(c *gin.Context) {
                                    var err *HttpError
                                    var resp interface{}
                                
                                    if c.Request.Method == http.MethodGet || c.Request.Method == "" {
                                Severity: Minor
                                Found in api/rest.go - About 1 hr to fix

                                Cognitive Complexity

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

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

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

                                Further reading

                                Function handleFilesList has 11 return statements (exceeds 4 allowed).
                                Open

                                func handleFilesList(cp utils.ContextProvider, exec boil.Executor, r FilesRequest) (*FilesResponse, *HttpError) {
                                    mods := make([]qm.QueryMod, 0)
                                    appendPermissionsMods(cp, &mods)
                                
                                    // filters
                                Severity: Major
                                Found in api/rest.go - About 1 hr to fix

                                  Function handleCollectionsList has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                                  Open

                                  func handleCollectionsList(cp utils.ContextProvider, exec boil.Executor, r CollectionsRequest) (*CollectionsResponse, *HttpError) {
                                      mods := make([]qm.QueryMod, 0)
                                      appendPermissionsMods(cp, &mods)
                                  
                                      // filters
                                  Severity: Minor
                                  Found in api/rest.go - About 1 hr to fix

                                    Function ContentUnitDerivativesHandler has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                                    Open

                                    func ContentUnitDerivativesHandler(c *gin.Context) {
                                        id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                                        if e != nil {
                                            NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                                            return
                                    Severity: Minor
                                    Found in api/rest.go - About 1 hr to fix

                                      Function handleUpdateContentUnit has 10 return statements (exceeds 4 allowed).
                                      Open

                                      func handleUpdateContentUnit(cp utils.ContextProvider, exec boil.Executor, cu *PartialContentUnit) (*ContentUnit, *HttpError) {
                                          unit, err := models.FindContentUnit(exec, cu.ID)
                                          if err != nil {
                                              if err == sql.ErrNoRows {
                                                  return nil, NewNotFoundError()
                                      Severity: Major
                                      Found in api/rest.go - About 1 hr to fix

                                        Function handleCollectionAddCCU has 10 return statements (exceeds 4 allowed).
                                        Open

                                        func handleCollectionAddCCU(cp utils.ContextProvider, exec boil.Executor, id int64, ccus []*models.CollectionsContentUnit) ([]events.Event, *HttpError) {
                                            c, err := models.FindCollection(exec, id)
                                            if err != nil {
                                                if err == sql.ErrNoRows {
                                                    return nil, NewNotFoundError()
                                        Severity: Major
                                        Found in api/rest.go - About 1 hr to fix

                                          Function handleCreateSource has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                                          Open

                                          func handleCreateSource(exec boil.Executor, r CreateSourceRequest) (*Source, *HttpError) {
                                              s := r.Source
                                          
                                              // check pattern unique constraint
                                              if s.Pattern.Valid {
                                          Severity: Minor
                                          Found in api/rest.go - About 55 mins to fix

                                          Cognitive Complexity

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

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

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

                                          Further reading

                                          Function handleContentUnitAddFiles has 9 return statements (exceeds 4 allowed).
                                          Open

                                          func handleContentUnitAddFiles(cp utils.ContextProvider, exec boil.Executor, id int64, fileIDs []int64) (*ContentUnit, []events.Event, *HttpError) {
                                              unit, err := models.FindContentUnit(exec, id)
                                              if err != nil {
                                                  if err == sql.ErrNoRows {
                                                      return nil, nil, NewNotFoundError()
                                          Severity: Major
                                          Found in api/rest.go - About 55 mins to fix

                                            Function handleContentUnitAddCUD has 9 return statements (exceeds 4 allowed).
                                            Open

                                            func handleContentUnitAddCUD(cp utils.ContextProvider, exec boil.Executor, id int64, cud models.ContentUnitDerivation) (*models.ContentUnit, *HttpError) {
                                                cu, err := models.FindContentUnit(exec, id)
                                                if err != nil {
                                                    if err == sql.ErrNoRows {
                                                        return nil, NewNotFoundError()
                                            Severity: Major
                                            Found in api/rest.go - About 55 mins to fix

                                              Function handleContentUnitAddSource has 9 return statements (exceeds 4 allowed).
                                              Open

                                              func handleContentUnitAddSource(cp utils.ContextProvider, exec boil.Executor, id int64, sourceID int64) (*models.ContentUnit, *HttpError) {
                                                  cu, err := models.FindContentUnit(exec, id)
                                                  if err != nil {
                                                      if err == sql.ErrNoRows {
                                                          return nil, NewNotFoundError()
                                              Severity: Major
                                              Found in api/rest.go - About 55 mins to fix

                                                Function handleContentUnitAddTag has 9 return statements (exceeds 4 allowed).
                                                Open

                                                func handleContentUnitAddTag(cp utils.ContextProvider, exec boil.Executor, id int64, tagID int64) (*models.ContentUnit, *HttpError) {
                                                    cu, err := models.FindContentUnit(exec, id)
                                                    if err != nil {
                                                        if err == sql.ErrNoRows {
                                                            return nil, NewNotFoundError()
                                                Severity: Major
                                                Found in api/rest.go - About 55 mins to fix

                                                  Function handleCollectionAddCCU has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                                                  Open

                                                  func handleCollectionAddCCU(cp utils.ContextProvider, exec boil.Executor, id int64, ccus []*models.CollectionsContentUnit) ([]events.Event, *HttpError) {
                                                      c, err := models.FindCollection(exec, id)
                                                      if err != nil {
                                                          if err == sql.ErrNoRows {
                                                              return nil, NewNotFoundError()
                                                  Severity: Minor
                                                  Found in api/rest.go - About 55 mins to fix

                                                  Cognitive Complexity

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

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

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

                                                  Further reading

                                                  Function handleCollectionRemoveCCU has 9 return statements (exceeds 4 allowed).
                                                  Open

                                                  func handleCollectionRemoveCCU(cp utils.ContextProvider, exec boil.Executor, id int64, cuID int64) ([]events.Event, *HttpError) {
                                                      c, err := models.FindCollection(exec, id)
                                                      if err != nil {
                                                          if err == sql.ErrNoRows {
                                                              return nil, NewNotFoundError()
                                                  Severity: Major
                                                  Found in api/rest.go - About 55 mins to fix

                                                    Function handleContentUnitAddPublisher has 9 return statements (exceeds 4 allowed).
                                                    Open

                                                    func handleContentUnitAddPublisher(cp utils.ContextProvider, exec boil.Executor, id int64, publisherID int64) (*models.ContentUnit, *HttpError) {
                                                        cu, err := models.FindContentUnit(exec, id)
                                                        if err != nil {
                                                            if err == sql.ErrNoRows {
                                                                return nil, NewNotFoundError()
                                                    Severity: Major
                                                    Found in api/rest.go - About 55 mins to fix

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

                                                      func handleCreateLabel(cp utils.ContextProvider, exec boil.Executor, r *CreateLabelRequest) (*models.Label, *HttpError) {
                                                          cu, err := models.ContentUnits(
                                                              qm.WhereIn("uid = ?", r.ContentUnit),
                                                              qm.Where("secure <= ?", allowedSecure(cp, common.PERM_LABEL_WRITE)),
                                                          ).One(exec)
                                                      Severity: Major
                                                      Found in api/rest.go - About 50 mins to fix

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

                                                        func handlePublishersList(exec boil.Executor, r PublishersRequest) (*PublishersResponse, *HttpError) {
                                                            mods := make([]qm.QueryMod, 0)
                                                        
                                                            // filters
                                                            if err := appendIDsFilterMods(&mods, r.IDsFilter); err != nil {
                                                        Severity: Major
                                                        Found in api/rest.go - About 50 mins to fix

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

                                                          func handlePersonsList(exec boil.Executor, r PersonsRequest) (*PersonsResponse, *HttpError) {
                                                              mods := make([]qm.QueryMod, 0)
                                                          
                                                              // filters
                                                              if err := appendIDsFilterMods(&mods, r.IDsFilter); err != nil {
                                                          Severity: Major
                                                          Found in api/rest.go - About 50 mins to fix

                                                            Function handleUpdateCollection has 7 return statements (exceeds 4 allowed).
                                                            Open

                                                            func handleUpdateCollection(cp utils.ContextProvider, exec boil.Executor, c *PartialCollection) (*Collection, *HttpError) {
                                                                collection, err := models.FindCollection(exec, c.ID)
                                                                if err != nil {
                                                                    if err == sql.ErrNoRows {
                                                                        return nil, NewNotFoundError()
                                                            Severity: Major
                                                            Found in api/rest.go - About 45 mins to fix

                                                              Function handleAddLabelI18n has 7 return statements (exceeds 4 allowed).
                                                              Open

                                                              func handleAddLabelI18n(cp utils.ContextProvider, exec boil.Executor, uid string, r *AddLabelI18nRequest, user *models.User) (*models.Label, *HttpError) {
                                                                  if common.StdLang(r.I18n.Language) == common.LANG_UNKNOWN {
                                                                      return nil, NewBadRequestError(errors.Errorf("Unknown language %s", r.I18n.Language))
                                                                  }
                                                              
                                                              
                                                              Severity: Major
                                                              Found in api/rest.go - About 45 mins to fix

                                                                Function handleCollectionUpdateCCU has 7 return statements (exceeds 4 allowed).
                                                                Open

                                                                func handleCollectionUpdateCCU(cp utils.ContextProvider, exec boil.Executor, id int64, ccu models.CollectionsContentUnit) (*events.Event, *HttpError) {
                                                                    c, err := models.FindCollection(exec, id)
                                                                    if err != nil {
                                                                        if err == sql.ErrNoRows {
                                                                            return nil, NewNotFoundError()
                                                                Severity: Major
                                                                Found in api/rest.go - About 45 mins to fix

                                                                  Function handleUpdateCollectionI18n has 7 return statements (exceeds 4 allowed).
                                                                  Open

                                                                  func handleUpdateCollectionI18n(cp utils.ContextProvider, exec boil.Executor, id int64, i18ns []*models.CollectionI18n) (*Collection, *HttpError) {
                                                                      collection, err := handleGetCollection(cp, exec, id)
                                                                      if err != nil {
                                                                          return nil, err
                                                                      }
                                                                  Severity: Major
                                                                  Found in api/rest.go - About 45 mins to fix

                                                                    Function handleContentUnitOrigins has 7 return statements (exceeds 4 allowed).
                                                                    Open

                                                                    func handleContentUnitOrigins(cp utils.ContextProvider, exec boil.Executor, id int64) ([]*ContentUnitDerivation, *HttpError) {
                                                                        unit, err := models.FindContentUnit(exec, id)
                                                                        if err != nil {
                                                                            if err == sql.ErrNoRows {
                                                                                return nil, NewNotFoundError()
                                                                    Severity: Major
                                                                    Found in api/rest.go - About 45 mins to fix

                                                                      Function handleCollectionCCU has 7 return statements (exceeds 4 allowed).
                                                                      Open

                                                                      func handleCollectionCCU(cp utils.ContextProvider, exec boil.Executor, id int64) ([]*CollectionContentUnit, *HttpError) {
                                                                          collection, err := models.FindCollection(exec, id)
                                                                          if err != nil {
                                                                              if err == sql.ErrNoRows {
                                                                                  return nil, NewNotFoundError()
                                                                      Severity: Major
                                                                      Found in api/rest.go - About 45 mins to fix

                                                                        Function handleContentUnitCCU has 7 return statements (exceeds 4 allowed).
                                                                        Open

                                                                        func handleContentUnitCCU(cp utils.ContextProvider, exec boil.Executor, id int64) ([]*CollectionContentUnit, *HttpError) {
                                                                            unit, err := models.FindContentUnit(exec, id)
                                                                            if err != nil {
                                                                                if err == sql.ErrNoRows {
                                                                                    return nil, NewNotFoundError()
                                                                        Severity: Major
                                                                        Found in api/rest.go - About 45 mins to fix

                                                                          Function handleContentUnitRemovePerson has 7 return statements (exceeds 4 allowed).
                                                                          Open

                                                                          func handleContentUnitRemovePerson(cp utils.ContextProvider, exec boil.Executor, id int64, personID int64) (*models.ContentUnit, *HttpError) {
                                                                              cu, err := models.FindContentUnit(exec, id)
                                                                              if err != nil {
                                                                                  if err == sql.ErrNoRows {
                                                                                      return nil, NewNotFoundError()
                                                                          Severity: Major
                                                                          Found in api/rest.go - About 45 mins to fix

                                                                            Function handleContentUnitRemoveCUD has 7 return statements (exceeds 4 allowed).
                                                                            Open

                                                                            func handleContentUnitRemoveCUD(cp utils.ContextProvider, exec boil.Executor, id int64, duID int64) (*models.ContentUnit, *HttpError) {
                                                                                cu, err := models.FindContentUnit(exec, id)
                                                                                if err != nil {
                                                                                    if err == sql.ErrNoRows {
                                                                                        return nil, NewNotFoundError()
                                                                            Severity: Major
                                                                            Found in api/rest.go - About 45 mins to fix

                                                                              Function handleOperationsList has 7 return statements (exceeds 4 allowed).
                                                                              Open

                                                                              func handleOperationsList(exec boil.Executor, r OperationsRequest) (*OperationsResponse, *HttpError) {
                                                                                  mods := make([]qm.QueryMod, 0)
                                                                              
                                                                                  // filters
                                                                                  if err := appendDateRangeFilterMods(&mods, r.DateRangeFilter, "created_at"); err != nil {
                                                                              Severity: Major
                                                                              Found in api/rest.go - About 45 mins to fix

                                                                                Function handleContentUnitRemoveTag has 7 return statements (exceeds 4 allowed).
                                                                                Open

                                                                                func handleContentUnitRemoveTag(cp utils.ContextProvider, exec boil.Executor, id int64, tagID int64) (*models.ContentUnit, *HttpError) {
                                                                                    cu, err := models.FindContentUnit(exec, id)
                                                                                    if err != nil {
                                                                                        if err == sql.ErrNoRows {
                                                                                            return nil, NewNotFoundError()
                                                                                Severity: Major
                                                                                Found in api/rest.go - About 45 mins to fix

                                                                                  Function handleContentUnitCUD has 7 return statements (exceeds 4 allowed).
                                                                                  Open

                                                                                  func handleContentUnitCUD(cp utils.ContextProvider, exec boil.Executor, id int64) ([]*ContentUnitDerivation, *HttpError) {
                                                                                      unit, err := models.FindContentUnit(exec, id)
                                                                                      if err != nil {
                                                                                          if err == sql.ErrNoRows {
                                                                                              return nil, NewNotFoundError()
                                                                                  Severity: Major
                                                                                  Found in api/rest.go - About 45 mins to fix

                                                                                    Function handleContentUnitUpdateCUD has 7 return statements (exceeds 4 allowed).
                                                                                    Open

                                                                                    func handleContentUnitUpdateCUD(cp utils.ContextProvider, exec boil.Executor, id int64, cud models.ContentUnitDerivation) (*models.ContentUnit, *HttpError) {
                                                                                        cu, err := models.FindContentUnit(exec, id)
                                                                                        if err != nil {
                                                                                            if err == sql.ErrNoRows {
                                                                                                return nil, NewNotFoundError()
                                                                                    Severity: Major
                                                                                    Found in api/rest.go - About 45 mins to fix

                                                                                      Function handleContentUnitRemovePublisher has 7 return statements (exceeds 4 allowed).
                                                                                      Open

                                                                                      func handleContentUnitRemovePublisher(cp utils.ContextProvider, exec boil.Executor, id int64, publisherID int64) (*models.ContentUnit, *HttpError) {
                                                                                          cu, err := models.FindContentUnit(exec, id)
                                                                                          if err != nil {
                                                                                              if err == sql.ErrNoRows {
                                                                                                  return nil, NewNotFoundError()
                                                                                      Severity: Major
                                                                                      Found in api/rest.go - About 45 mins to fix

                                                                                        Function handleDeleteCollection has 7 return statements (exceeds 4 allowed).
                                                                                        Open

                                                                                        func handleDeleteCollection(cp utils.ContextProvider, exec boil.Executor, id int64) (*models.Collection, *HttpError) {
                                                                                            collection, err := models.FindCollection(exec, id)
                                                                                            if err != nil {
                                                                                                if err == sql.ErrNoRows {
                                                                                                    return nil, NewNotFoundError()
                                                                                        Severity: Major
                                                                                        Found in api/rest.go - About 45 mins to fix

                                                                                          Function handleGetLabelList has 7 return statements (exceeds 4 allowed).
                                                                                          Open

                                                                                          func handleGetLabelList(cp utils.ContextProvider, exec boil.Executor, r *LabelsRequest) (*LabelsResponse, *HttpError) {
                                                                                              mods := []qm.QueryMod{
                                                                                                  qm.InnerJoin("content_units cu on cu.id=content_unit_id and cu.secure <= ?", allowedSecure(cp, common.PERM_LABEL_READ)),
                                                                                              }
                                                                                          
                                                                                          
                                                                                          Severity: Major
                                                                                          Found in api/rest.go - About 45 mins to fix

                                                                                            Function handleContentUnitRemoveSource has 7 return statements (exceeds 4 allowed).
                                                                                            Open

                                                                                            func handleContentUnitRemoveSource(cp utils.ContextProvider, exec boil.Executor, id int64, sourceID int64) (*models.ContentUnit, *HttpError) {
                                                                                                cu, err := models.FindContentUnit(exec, id)
                                                                                                if err != nil {
                                                                                                    if err == sql.ErrNoRows {
                                                                                                        return nil, NewNotFoundError()
                                                                                            Severity: Major
                                                                                            Found in api/rest.go - About 45 mins to fix

                                                                                              Function handleUpdateFile has 7 return statements (exceeds 4 allowed).
                                                                                              Open

                                                                                              func handleUpdateFile(cp utils.ContextProvider, exec boil.Executor, f *PartialFile) (*MFile, []events.Event, *HttpError) {
                                                                                                  file, err := models.FindFile(exec, f.ID)
                                                                                                  if err != nil {
                                                                                                      if err == sql.ErrNoRows {
                                                                                                          return nil, nil, NewNotFoundError()
                                                                                              Severity: Major
                                                                                              Found in api/rest.go - About 45 mins to fix

                                                                                                Function allowedSecure has 6 return statements (exceeds 4 allowed).
                                                                                                Open

                                                                                                func allowedSecure(cp utils.ContextProvider, act string) int16 {
                                                                                                    if can(cp, secureToPermission(common.SEC_PRIVATE), act) {
                                                                                                        return common.SEC_PRIVATE
                                                                                                    } else if can(cp, secureToPermission(common.SEC_SENSITIVE), act) {
                                                                                                        return common.SEC_SENSITIVE
                                                                                                Severity: Major
                                                                                                Found in api/rest.go - About 40 mins to fix

                                                                                                  Function SourcesHandler has 6 return statements (exceeds 4 allowed).
                                                                                                  Open

                                                                                                  func SourcesHandler(c *gin.Context) {
                                                                                                      var err *HttpError
                                                                                                      var resp interface{}
                                                                                                  
                                                                                                      if c.Request.Method == http.MethodGet || c.Request.Method == "" {
                                                                                                  Severity: Major
                                                                                                  Found in api/rest.go - About 40 mins to fix

                                                                                                    Function handleUpdateContentUnitI18n has 6 return statements (exceeds 4 allowed).
                                                                                                    Open

                                                                                                    func handleUpdateContentUnitI18n(cp utils.ContextProvider, exec boil.Executor, id int64, i18ns []*models.ContentUnitI18n) (*ContentUnit, *HttpError) {
                                                                                                        unit, err := handleGetContentUnit(cp, exec, id)
                                                                                                        if err != nil {
                                                                                                            return nil, err
                                                                                                        }
                                                                                                    Severity: Major
                                                                                                    Found in api/rest.go - About 40 mins to fix

                                                                                                      Function handleCollectionActivate has 6 return statements (exceeds 4 allowed).
                                                                                                      Open

                                                                                                      func handleCollectionActivate(cp utils.ContextProvider, exec boil.Executor, id int64) (*Collection, *HttpError) {
                                                                                                          collection, err := models.FindCollection(exec, id)
                                                                                                          if err != nil {
                                                                                                              if err == sql.ErrNoRows {
                                                                                                                  return nil, NewNotFoundError()
                                                                                                      Severity: Major
                                                                                                      Found in api/rest.go - About 40 mins to fix

                                                                                                        Function handleCreateTag has 6 return statements (exceeds 4 allowed).
                                                                                                        Open

                                                                                                        func handleCreateTag(exec boil.Executor, t *Tag) (*Tag, *HttpError) {
                                                                                                            // make sure parent tag exists if given
                                                                                                            if t.ParentID.Valid {
                                                                                                                ok, err := models.Tags(qm.Where("id = ?", t.ParentID.Int64)).Exists(exec)
                                                                                                                if err != nil {
                                                                                                        Severity: Major
                                                                                                        Found in api/rest.go - About 40 mins to fix

                                                                                                          Function handleDeletePerson has 6 return statements (exceeds 4 allowed).
                                                                                                          Open

                                                                                                          func handleDeletePerson(exec boil.Executor, id int64) (*models.Person, *HttpError) {
                                                                                                              person, err := models.FindPerson(exec, id)
                                                                                                              if err != nil {
                                                                                                                  if err == sql.ErrNoRows {
                                                                                                                      return nil, NewNotFoundError()
                                                                                                          Severity: Major
                                                                                                          Found in api/rest.go - About 40 mins to fix

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

                                                                                                            func handleAddLabelI18n(cp utils.ContextProvider, exec boil.Executor, uid string, r *AddLabelI18nRequest, user *models.User) (*models.Label, *HttpError) {
                                                                                                            Severity: Minor
                                                                                                            Found in api/rest.go - About 35 mins to fix

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

                                                                                                              func PersonsListHandler(c *gin.Context) {
                                                                                                                  var err *HttpError
                                                                                                                  var resp interface{}
                                                                                                              
                                                                                                                  switch c.Request.Method {
                                                                                                              Severity: Major
                                                                                                              Found in api/rest.go - About 35 mins to fix

                                                                                                                Function handleContentUnitAddFiles has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                                                                                                                Open

                                                                                                                func handleContentUnitAddFiles(cp utils.ContextProvider, exec boil.Executor, id int64, fileIDs []int64) (*ContentUnit, []events.Event, *HttpError) {
                                                                                                                    unit, err := models.FindContentUnit(exec, id)
                                                                                                                    if err != nil {
                                                                                                                        if err == sql.ErrNoRows {
                                                                                                                            return nil, nil, NewNotFoundError()
                                                                                                                Severity: Minor
                                                                                                                Found in api/rest.go - About 35 mins to fix

                                                                                                                Cognitive Complexity

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

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

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

                                                                                                                Further reading

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

                                                                                                                func handleContentUnitFiles(cp utils.ContextProvider, exec boil.Executor, id int64) ([]*MFile, *HttpError) {
                                                                                                                    unit, err := models.FindContentUnit(exec, id)
                                                                                                                    if err != nil {
                                                                                                                        if err == sql.ErrNoRows {
                                                                                                                            return nil, NewNotFoundError()
                                                                                                                Severity: Major
                                                                                                                Found in api/rest.go - About 35 mins to fix

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

                                                                                                                  func handleGetSources(exec boil.Executor, r SourcesRequest) (*SourcesResponse, *HttpError) {
                                                                                                                      mods := make([]qm.QueryMod, 0)
                                                                                                                  
                                                                                                                      // count query
                                                                                                                      var total int64
                                                                                                                  Severity: Major
                                                                                                                  Found in api/rest.go - About 35 mins to fix

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

                                                                                                                    func getUniqSourceAndCUUID(exec boil.Executor, attempts int64) (string, error) {
                                                                                                                        if attempts > 10 {
                                                                                                                            return "", errors.New("Too match attempts of find unique UID for CU and Source")
                                                                                                                        }
                                                                                                                        uid, err := GetFreeUID(exec, new(SourceUIDChecker))
                                                                                                                    Severity: Major
                                                                                                                    Found in api/rest.go - About 35 mins to fix

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

                                                                                                                      func handleCreateContentUnit(cp utils.ContextProvider, exec boil.Executor, cu ContentUnit) (*ContentUnit, *HttpError) {
                                                                                                                          // check object level permissions
                                                                                                                          if !can(cp, secureToPermission(cu.Secure), common.PERM_WRITE) {
                                                                                                                              return nil, NewForbiddenError()
                                                                                                                          }
                                                                                                                      Severity: Major
                                                                                                                      Found in api/rest.go - About 35 mins to fix

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

                                                                                                                        func appendSearchTermFilterMods(exec boil.Executor, mods *[]qm.QueryMod, f SearchTermFilter, entityType int) error {
                                                                                                                            if f.Query == "" {
                                                                                                                                return nil
                                                                                                                            }
                                                                                                                        
                                                                                                                        
                                                                                                                        Severity: Major
                                                                                                                        Found in api/rest.go - About 35 mins to fix

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

                                                                                                                          func TagsHandler(c *gin.Context) {
                                                                                                                              var err *HttpError
                                                                                                                              var resp interface{}
                                                                                                                          
                                                                                                                              if c.Request.Method == http.MethodGet || c.Request.Method == "" {
                                                                                                                          Severity: Major
                                                                                                                          Found in api/rest.go - About 35 mins to fix

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

                                                                                                                            func handleCollectionContentUnitsPosition(exec boil.Executor, id int64, orderType string) (*events.Event, *HttpError) {
                                                                                                                                collection, err := models.FindCollection(exec, id)
                                                                                                                                event := events.CollectionContentUnitsChangeEvent(collection)
                                                                                                                                all, err := models.CollectionsContentUnits(
                                                                                                                                    qm.Load("ContentUnit"),
                                                                                                                            Severity: Major
                                                                                                                            Found in api/rest.go - About 35 mins to fix

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

                                                                                                                              func handleFileStorages(cp utils.ContextProvider, exec boil.Executor, id int64) ([]*Storage, *HttpError) {
                                                                                                                                  file, err := models.FindFile(exec, id)
                                                                                                                                  if err != nil {
                                                                                                                                      if err == sql.ErrNoRows {
                                                                                                                                          return nil, NewNotFoundError()
                                                                                                                              Severity: Major
                                                                                                                              Found in api/rest.go - About 35 mins to fix

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

                                                                                                                                func handleStoragesList(exec boil.Executor, r StoragesRequest) (*StoragesResponse, *HttpError) {
                                                                                                                                    mods := make([]qm.QueryMod, 0)
                                                                                                                                
                                                                                                                                    // count query
                                                                                                                                    var total int64
                                                                                                                                Severity: Major
                                                                                                                                Found in api/rest.go - About 35 mins to fix

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

                                                                                                                                  func PublishersHandler(c *gin.Context) {
                                                                                                                                      var err *HttpError
                                                                                                                                      var resp interface{}
                                                                                                                                  
                                                                                                                                      switch c.Request.Method {
                                                                                                                                  Severity: Major
                                                                                                                                  Found in api/rest.go - About 35 mins to fix

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

                                                                                                                                    func handleCreateCollection(cp utils.ContextProvider, exec boil.Executor, c Collection) (*Collection, *HttpError) {
                                                                                                                                        // check object level permissions
                                                                                                                                        if !can(cp, secureToPermission(c.Secure), common.PERM_WRITE) {
                                                                                                                                            return nil, NewForbiddenError()
                                                                                                                                        }
                                                                                                                                    Severity: Major
                                                                                                                                    Found in api/rest.go - About 35 mins to fix

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

                                                                                                                                      func appendSourcesFilterMods(exec boil.Executor, mods *[]qm.QueryMod, f SourcesFilter) error {
                                                                                                                                          if utils.IsEmpty(f.Authors) && len(f.Sources) == 0 {
                                                                                                                                              return nil
                                                                                                                                          }
                                                                                                                                      
                                                                                                                                      
                                                                                                                                      Severity: Major
                                                                                                                                      Found in api/rest.go - About 35 mins to fix

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

                                                                                                                                        func PersonHandler(c *gin.Context) {
                                                                                                                                            id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                                                                                                                                            if e != nil {
                                                                                                                                                NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                                                                                                                                                return
                                                                                                                                        Severity: Major
                                                                                                                                        Found in api/rest.go - About 35 mins to fix

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

                                                                                                                                          func handleGetTags(exec boil.Executor, r TagsRequest) (*TagsResponse, *HttpError) {
                                                                                                                                              mods := make([]qm.QueryMod, 0)
                                                                                                                                          
                                                                                                                                              // count query
                                                                                                                                              var total int64
                                                                                                                                          Severity: Major
                                                                                                                                          Found in api/rest.go - About 35 mins to fix

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

                                                                                                                                            func handlePersonsList(exec boil.Executor, r PersonsRequest) (*PersonsResponse, *HttpError) {
                                                                                                                                                mods := make([]qm.QueryMod, 0)
                                                                                                                                            
                                                                                                                                                // filters
                                                                                                                                                if err := appendIDsFilterMods(&mods, r.IDsFilter); err != nil {
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 7 hrs to fix
                                                                                                                                            api/rest.go on lines 4232..4286

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

                                                                                                                                            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 handlePublishersList(exec boil.Executor, r PublishersRequest) (*PublishersResponse, *HttpError) {
                                                                                                                                                mods := make([]qm.QueryMod, 0)
                                                                                                                                            
                                                                                                                                                // filters
                                                                                                                                                if err := appendIDsFilterMods(&mods, r.IDsFilter); err != nil {
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 7 hrs to fix
                                                                                                                                            api/rest.go on lines 4017..4071

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

                                                                                                                                            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 ContentUnitSourcesHandler(c *gin.Context) {
                                                                                                                                                id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                                                                                                                                                if e != nil {
                                                                                                                                                    NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                                                                                                                                                    return
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 6 hrs to fix
                                                                                                                                            api/rest.go on lines 550..599

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

                                                                                                                                            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 ContentUnitTagsHandler(c *gin.Context) {
                                                                                                                                                id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                                                                                                                                                if e != nil {
                                                                                                                                                    NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                                                                                                                                                    return
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 6 hrs to fix
                                                                                                                                            api/rest.go on lines 500..548

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

                                                                                                                                            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 handleGetSources(exec boil.Executor, r SourcesRequest) (*SourcesResponse, *HttpError) {
                                                                                                                                                mods := make([]qm.QueryMod, 0)
                                                                                                                                            
                                                                                                                                                // count query
                                                                                                                                                var total int64
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 5 hrs to fix
                                                                                                                                            api/rest.go on lines 3860..3903

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

                                                                                                                                            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 handleGetTags(exec boil.Executor, r TagsRequest) (*TagsResponse, *HttpError) {
                                                                                                                                                mods := make([]qm.QueryMod, 0)
                                                                                                                                            
                                                                                                                                                // count query
                                                                                                                                                var total int64
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 5 hrs to fix
                                                                                                                                            api/rest.go on lines 3630..3673

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

                                                                                                                                            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 PublishersHandler(c *gin.Context) {
                                                                                                                                                var err *HttpError
                                                                                                                                                var resp interface{}
                                                                                                                                            
                                                                                                                                                switch c.Request.Method {
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 5 hrs to fix
                                                                                                                                            api/rest.go on lines 1177..1223

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

                                                                                                                                            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 PersonsListHandler(c *gin.Context) {
                                                                                                                                                var err *HttpError
                                                                                                                                                var resp interface{}
                                                                                                                                            
                                                                                                                                                switch c.Request.Method {
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 5 hrs to fix
                                                                                                                                            api/rest.go on lines 1314..1360

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

                                                                                                                                            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 CollectionsListHandler(c *gin.Context) {
                                                                                                                                                var err *HttpError
                                                                                                                                                var resp interface{}
                                                                                                                                            
                                                                                                                                                switch c.Request.Method {
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 5 hrs to fix
                                                                                                                                            api/rest.go on lines 264..306

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

                                                                                                                                            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 ContentUnitsListHandler(c *gin.Context) {
                                                                                                                                                var err *HttpError
                                                                                                                                                var resp interface{}
                                                                                                                                            
                                                                                                                                                switch c.Request.Method {
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 5 hrs to fix
                                                                                                                                            api/rest.go on lines 41..83

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

                                                                                                                                            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

                                                                                                                                            func PublisherHandler(c *gin.Context) {
                                                                                                                                                id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                                                                                                                                                if e != nil {
                                                                                                                                                    NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                                                                                                                                                    return
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 5 hrs to fix
                                                                                                                                            api/rest.go on lines 976..1017
                                                                                                                                            api/rest.go on lines 1100..1141

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

                                                                                                                                            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

                                                                                                                                            func TagHandler(c *gin.Context) {
                                                                                                                                                id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                                                                                                                                                if e != nil {
                                                                                                                                                    NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                                                                                                                                                    return
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 5 hrs to fix
                                                                                                                                            api/rest.go on lines 976..1017
                                                                                                                                            api/rest.go on lines 1362..1403

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

                                                                                                                                            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

                                                                                                                                            func SourceHandler(c *gin.Context) {
                                                                                                                                                id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                                                                                                                                                if e != nil {
                                                                                                                                                    NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                                                                                                                                                    return
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 5 hrs to fix
                                                                                                                                            api/rest.go on lines 1100..1141
                                                                                                                                            api/rest.go on lines 1362..1403

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

                                                                                                                                            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

                                                                                                                                            func handleContentUnitAddSource(cp utils.ContextProvider, exec boil.Executor, id int64, sourceID int64) (*models.ContentUnit, *HttpError) {
                                                                                                                                                cu, err := models.FindContentUnit(exec, id)
                                                                                                                                                if err != nil {
                                                                                                                                                    if err == sql.ErrNoRows {
                                                                                                                                                        return nil, NewNotFoundError()
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 4 hrs to fix
                                                                                                                                            api/rest.go on lines 2959..3002
                                                                                                                                            api/rest.go on lines 3191..3234

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

                                                                                                                                            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

                                                                                                                                            func handleContentUnitAddTag(cp utils.ContextProvider, exec boil.Executor, id int64, tagID int64) (*models.ContentUnit, *HttpError) {
                                                                                                                                                cu, err := models.FindContentUnit(exec, id)
                                                                                                                                                if err != nil {
                                                                                                                                                    if err == sql.ErrNoRows {
                                                                                                                                                        return nil, NewNotFoundError()
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 4 hrs to fix
                                                                                                                                            api/rest.go on lines 2849..2892
                                                                                                                                            api/rest.go on lines 3191..3234

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

                                                                                                                                            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

                                                                                                                                            func handleContentUnitAddPublisher(cp utils.ContextProvider, exec boil.Executor, id int64, publisherID int64) (*models.ContentUnit, *HttpError) {
                                                                                                                                                cu, err := models.FindContentUnit(exec, id)
                                                                                                                                                if err != nil {
                                                                                                                                                    if err == sql.ErrNoRows {
                                                                                                                                                        return nil, NewNotFoundError()
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 4 hrs to fix
                                                                                                                                            api/rest.go on lines 2849..2892
                                                                                                                                            api/rest.go on lines 2959..3002

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

                                                                                                                                            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

                                                                                                                                            func handleGetContentUnitPublishers(cp utils.ContextProvider, exec boil.Executor, id int64) ([]*Publisher, *HttpError) {
                                                                                                                                                unit, err := models.ContentUnits(
                                                                                                                                                    qm.Where("id = ?", id),
                                                                                                                                                    qm.Load("Publishers"),
                                                                                                                                                    qm.Load("Publishers.PublisherI18ns")).
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 4 hrs to fix
                                                                                                                                            api/rest.go on lines 2816..2847
                                                                                                                                            api/rest.go on lines 2926..2957

                                                                                                                                            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

                                                                                                                                            func handleGetContentUnitTags(cp utils.ContextProvider, exec boil.Executor, id int64) ([]*Tag, *HttpError) {
                                                                                                                                                unit, err := models.ContentUnits(
                                                                                                                                                    qm.Where("id = ?", id),
                                                                                                                                                    qm.Load("Tags"),
                                                                                                                                                    qm.Load("Tags.TagI18ns")).
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 4 hrs to fix
                                                                                                                                            api/rest.go on lines 2816..2847
                                                                                                                                            api/rest.go on lines 3158..3189

                                                                                                                                            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

                                                                                                                                            func handleGetContentUnitSources(cp utils.ContextProvider, exec boil.Executor, id int64) ([]*Source, *HttpError) {
                                                                                                                                                unit, err := models.ContentUnits(
                                                                                                                                                    qm.Where("id = ?", id),
                                                                                                                                                    qm.Load("Sources"),
                                                                                                                                                    qm.Load("Sources.SourceI18ns")).
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 4 hrs to fix
                                                                                                                                            api/rest.go on lines 2926..2957
                                                                                                                                            api/rest.go on lines 3158..3189

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

                                                                                                                                            func PublisherI18nHandler(c *gin.Context) {
                                                                                                                                                if !isAdmin(c) {
                                                                                                                                                    NewForbiddenError().Abort(c)
                                                                                                                                                    return
                                                                                                                                                }
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 3 other locations - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 1019..1051
                                                                                                                                            api/rest.go on lines 1143..1175
                                                                                                                                            api/rest.go on lines 1280..1312

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

                                                                                                                                            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 TagI18nHandler(c *gin.Context) {
                                                                                                                                                if !isAdmin(c) {
                                                                                                                                                    NewForbiddenError().Abort(c)
                                                                                                                                                    return
                                                                                                                                                }
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 3 other locations - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 1019..1051
                                                                                                                                            api/rest.go on lines 1280..1312
                                                                                                                                            api/rest.go on lines 1405..1437

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

                                                                                                                                            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 SourceI18nHandler(c *gin.Context) {
                                                                                                                                                if !isAdmin(c) {
                                                                                                                                                    NewForbiddenError().Abort(c)
                                                                                                                                                    return
                                                                                                                                                }
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 3 other locations - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 1143..1175
                                                                                                                                            api/rest.go on lines 1280..1312
                                                                                                                                            api/rest.go on lines 1405..1437

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

                                                                                                                                            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 PersonI18nHandler(c *gin.Context) {
                                                                                                                                                if !isAdmin(c) {
                                                                                                                                                    NewForbiddenError().Abort(c)
                                                                                                                                                    return
                                                                                                                                                }
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 3 other locations - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 1019..1051
                                                                                                                                            api/rest.go on lines 1143..1175
                                                                                                                                            api/rest.go on lines 1405..1437

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

                                                                                                                                            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 handleCreateContentUnit(cp utils.ContextProvider, exec boil.Executor, cu ContentUnit) (*ContentUnit, *HttpError) {
                                                                                                                                                // check object level permissions
                                                                                                                                                if !can(cp, secureToPermission(cu.Secure), common.PERM_WRITE) {
                                                                                                                                                    return nil, NewForbiddenError()
                                                                                                                                                }
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 1652..1683

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

                                                                                                                                            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 handleCreateCollection(cp utils.ContextProvider, exec boil.Executor, c Collection) (*Collection, *HttpError) {
                                                                                                                                                // check object level permissions
                                                                                                                                                if !can(cp, secureToPermission(c.Secure), common.PERM_WRITE) {
                                                                                                                                                    return nil, NewForbiddenError()
                                                                                                                                                }
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 2270..2301

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

                                                                                                                                            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

                                                                                                                                            func handleUpdateSourceI18n(exec boil.Executor, id int64, i18ns []*models.SourceI18n) (*Source, *HttpError) {
                                                                                                                                                source, err := handleGetSource(exec, id)
                                                                                                                                                if err != nil {
                                                                                                                                                    return nil, err
                                                                                                                                                }
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 4140..4171
                                                                                                                                            api/rest.go on lines 4355..4386

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

                                                                                                                                            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

                                                                                                                                            func handleUpdatePersonI18n(exec boil.Executor, id int64, i18ns []*models.PersonI18n) (*Person, *HttpError) {
                                                                                                                                                person, err := handleGetPerson(exec, id)
                                                                                                                                                if err != nil {
                                                                                                                                                    return nil, err
                                                                                                                                                }
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 3827..3858
                                                                                                                                            api/rest.go on lines 4355..4386

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

                                                                                                                                            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

                                                                                                                                            func handleUpdatePublisherI18n(exec boil.Executor, id int64, i18ns []*models.PublisherI18n) (*Publisher, *HttpError) {
                                                                                                                                                publisher, err := handleGetPublisher(exec, id)
                                                                                                                                                if err != nil {
                                                                                                                                                    return nil, err
                                                                                                                                                }
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 3827..3858
                                                                                                                                            api/rest.go on lines 4140..4171

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

                                                                                                                                            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

                                                                                                                                            func ContentUnitI18nHandler(c *gin.Context) {
                                                                                                                                                id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                                                                                                                                                if e != nil {
                                                                                                                                                    NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                                                                                                                                                    return
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 126..153
                                                                                                                                            api/rest.go on lines 1533..1560

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

                                                                                                                                            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

                                                                                                                                            func CollectionI18nHandler(c *gin.Context) {
                                                                                                                                                id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                                                                                                                                                if e != nil {
                                                                                                                                                    NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                                                                                                                                                    return
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 351..378
                                                                                                                                            api/rest.go on lines 1533..1560

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

                                                                                                                                            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

                                                                                                                                            func LabelI18nHandler(c *gin.Context) {
                                                                                                                                                id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                                                                                                                                                if e != nil {
                                                                                                                                                    NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                                                                                                                                                    return
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 126..153
                                                                                                                                            api/rest.go on lines 351..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 255.

                                                                                                                                            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 handleGetCollection(cp utils.ContextProvider, exec boil.Executor, id int64) (*Collection, *HttpError) {
                                                                                                                                                collection, err := models.Collections(qm.Where("id = ?", id), qm.Load("CollectionI18ns")).
                                                                                                                                                    One(exec)
                                                                                                                                                if err != nil {
                                                                                                                                                    if err == sql.ErrNoRows {
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 2245..2268

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

                                                                                                                                            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 handleGetContentUnit(cp utils.ContextProvider, exec boil.Executor, id int64) (*ContentUnit, *HttpError) {
                                                                                                                                                unit, err := models.ContentUnits(qm.Where("id = ?", id), qm.Load("ContentUnitI18ns")).One(exec)
                                                                                                                                                if err != nil {
                                                                                                                                                    if err == sql.ErrNoRows {
                                                                                                                                                        return nil, NewNotFoundError()
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 3 hrs to fix
                                                                                                                                            api/rest.go on lines 1685..1709

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

                                                                                                                                            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

                                                                                                                                            func handleContentUnitRemoveTag(cp utils.ContextProvider, exec boil.Executor, id int64, tagID int64) (*models.ContentUnit, *HttpError) {
                                                                                                                                                cu, err := models.FindContentUnit(exec, id)
                                                                                                                                                if err != nil {
                                                                                                                                                    if err == sql.ErrNoRows {
                                                                                                                                                        return nil, NewNotFoundError()
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 2 hrs to fix
                                                                                                                                            api/rest.go on lines 2894..2924
                                                                                                                                            api/rest.go on lines 3236..3266

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

                                                                                                                                            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

                                                                                                                                            func handleContentUnitRemovePublisher(cp utils.ContextProvider, exec boil.Executor, id int64, publisherID int64) (*models.ContentUnit, *HttpError) {
                                                                                                                                                cu, err := models.FindContentUnit(exec, id)
                                                                                                                                                if err != nil {
                                                                                                                                                    if err == sql.ErrNoRows {
                                                                                                                                                        return nil, NewNotFoundError()
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 2 hrs to fix
                                                                                                                                            api/rest.go on lines 2894..2924
                                                                                                                                            api/rest.go on lines 3004..3034

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

                                                                                                                                            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

                                                                                                                                            func handleContentUnitRemoveSource(cp utils.ContextProvider, exec boil.Executor, id int64, sourceID int64) (*models.ContentUnit, *HttpError) {
                                                                                                                                                cu, err := models.FindContentUnit(exec, id)
                                                                                                                                                if err != nil {
                                                                                                                                                    if err == sql.ErrNoRows {
                                                                                                                                                        return nil, NewNotFoundError()
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 2 hrs to fix
                                                                                                                                            api/rest.go on lines 3004..3034
                                                                                                                                            api/rest.go on lines 3236..3266

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

                                                                                                                                            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 handleContentUnitRemovePerson(cp utils.ContextProvider, exec boil.Executor, id int64, personID int64) (*models.ContentUnit, *HttpError) {
                                                                                                                                                cu, err := models.FindContentUnit(exec, id)
                                                                                                                                                if err != nil {
                                                                                                                                                    if err == sql.ErrNoRows {
                                                                                                                                                        return nil, NewNotFoundError()
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 2 hrs to fix
                                                                                                                                            api/rest.go on lines 2728..2758

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

                                                                                                                                            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 handleContentUnitRemoveCUD(cp utils.ContextProvider, exec boil.Executor, id int64, duID int64) (*models.ContentUnit, *HttpError) {
                                                                                                                                                cu, err := models.FindContentUnit(exec, id)
                                                                                                                                                if err != nil {
                                                                                                                                                    if err == sql.ErrNoRows {
                                                                                                                                                        return nil, NewNotFoundError()
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 2 hrs to fix
                                                                                                                                            api/rest.go on lines 3126..3156

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

                                                                                                                                            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 handleGetSource(exec boil.Executor, id int64) (*Source, *HttpError) {
                                                                                                                                                source, err := models.Sources(
                                                                                                                                                    qm.Where("id = ?", id),
                                                                                                                                                    qm.Load("SourceI18ns")).
                                                                                                                                                    One(exec)
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 3 other locations - About 2 hrs to fix
                                                                                                                                            api/rest.go on lines 3940..3961
                                                                                                                                            api/rest.go on lines 4117..4138
                                                                                                                                            api/rest.go on lines 4313..4334

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

                                                                                                                                            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 handleGetPerson(exec boil.Executor, id int64) (*Person, *HttpError) {
                                                                                                                                                person, err := models.Persons(
                                                                                                                                                    qm.Where("id = ?", id),
                                                                                                                                                    qm.Load("PersonI18ns")).
                                                                                                                                                    One(exec)
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 3 other locations - About 2 hrs to fix
                                                                                                                                            api/rest.go on lines 3779..3799
                                                                                                                                            api/rest.go on lines 3940..3961
                                                                                                                                            api/rest.go on lines 4313..4334

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

                                                                                                                                            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 handleGetTag(exec boil.Executor, id int64) (*Tag, *HttpError) {
                                                                                                                                                tag, err := models.Tags(
                                                                                                                                                    qm.Where("id = ?", id),
                                                                                                                                                    qm.Load("TagI18ns")).
                                                                                                                                                    One(exec)
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 3 other locations - About 2 hrs to fix
                                                                                                                                            api/rest.go on lines 3779..3799
                                                                                                                                            api/rest.go on lines 4117..4138
                                                                                                                                            api/rest.go on lines 4313..4334

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

                                                                                                                                            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 handleGetPublisher(exec boil.Executor, id int64) (*Publisher, *HttpError) {
                                                                                                                                                publisher, err := models.Publishers(
                                                                                                                                                    qm.Where("id = ?", id),
                                                                                                                                                    qm.Load("PublisherI18ns")).
                                                                                                                                                    One(exec)
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 3 other locations - About 2 hrs to fix
                                                                                                                                            api/rest.go on lines 3779..3799
                                                                                                                                            api/rest.go on lines 3940..3961
                                                                                                                                            api/rest.go on lines 4117..4138

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

                                                                                                                                            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 handleCreatePublisher(exec boil.Executor, p *Publisher) (*Publisher, *HttpError) {
                                                                                                                                            
                                                                                                                                                // save publisher to DB
                                                                                                                                                uid, err := GetFreeUID(exec, new(PublisherUIDChecker))
                                                                                                                                                if err != nil {
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 1 hr to fix
                                                                                                                                            api/rest.go on lines 4073..4096

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

                                                                                                                                            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 handleCreatePerson(exec boil.Executor, p *Person) (*Person, *HttpError) {
                                                                                                                                            
                                                                                                                                                // save person to DB
                                                                                                                                                uid, err := GetFreeUID(exec, new(PersonUIDChecker))
                                                                                                                                                if err != nil {
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 1 hr to fix
                                                                                                                                            api/rest.go on lines 4288..4311

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

                                                                                                                                            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 appendOperationTypesFilterMods(mods *[]qm.QueryMod, f OperationTypesFilter) error {
                                                                                                                                                if utils.IsEmpty(f.OperationTypes) {
                                                                                                                                                    return nil
                                                                                                                                                }
                                                                                                                                            
                                                                                                                                            
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 1 hr to fix
                                                                                                                                            api/rest.go on lines 4863..4881

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

                                                                                                                                            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 appendContentTypesFilterMods(mods *[]qm.QueryMod, f ContentTypesFilter) error {
                                                                                                                                                if utils.IsEmpty(f.ContentTypes) {
                                                                                                                                                    return nil
                                                                                                                                                }
                                                                                                                                            
                                                                                                                                            
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 1 hr to fix
                                                                                                                                            api/rest.go on lines 4910..4928

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

                                                                                                                                            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 handleUpdatePublisher(exec boil.Executor, p *Publisher) (*Publisher, *HttpError) {
                                                                                                                                                publisher, err := models.FindPublisher(exec, p.ID)
                                                                                                                                                if err != nil {
                                                                                                                                                    if err == sql.ErrNoRows {
                                                                                                                                                        return nil, NewNotFoundError()
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 1 hr to fix
                                                                                                                                            api/rest.go on lines 4098..4115

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

                                                                                                                                            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 handleUpdatePerson(exec boil.Executor, p *Person) (*Person, *HttpError) {
                                                                                                                                                person, err := models.FindPerson(exec, p.ID)
                                                                                                                                                if err != nil {
                                                                                                                                                    if err == sql.ErrNoRows {
                                                                                                                                                        return nil, NewNotFoundError()
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 1 hr to fix
                                                                                                                                            api/rest.go on lines 4336..4353

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

                                                                                                                                            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

                                                                                                                                                case SEARCH_IN_COLLECTIONS:
                                                                                                                                            
                                                                                                                                                    // get Collection IDs from search in i18ns
                                                                                                                                                    var ids pq.Int64Array
                                                                                                                                                    q := `select array_agg(c.id)
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 1 hr to fix
                                                                                                                                            api/rest.go on lines 4725..4741

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

                                                                                                                                            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

                                                                                                                                                case SEARCH_IN_CONTENT_UNITS:
                                                                                                                                            
                                                                                                                                                    // get CU IDs from search in i18ns
                                                                                                                                                    var ids pq.Int64Array
                                                                                                                                                    q := `select array_agg(cui.content_unit_id)
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 1 hr to fix
                                                                                                                                            api/rest.go on lines 4761..4777

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

                                                                                                                                            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 OperationsListHandler(c *gin.Context) {
                                                                                                                                                // check permissions
                                                                                                                                                if !can(c, secureToPermission(common.SEC_PUBLIC), common.PERM_READ) {
                                                                                                                                                    NewForbiddenError().Abort(c)
                                                                                                                                                    return
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 1 hr to fix
                                                                                                                                            api/rest.go on lines 1439..1452

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

                                                                                                                                            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 StoragesHandler(c *gin.Context) {
                                                                                                                                                if !can(c, secureToPermission(common.SEC_PUBLIC), common.PERM_READ) {
                                                                                                                                                    NewForbiddenError().Abort(c)
                                                                                                                                                    return
                                                                                                                                                }
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 1 other location - About 1 hr to fix
                                                                                                                                            api/rest.go on lines 834..848

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

                                                                                                                                            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

                                                                                                                                                case http.MethodDelete:
                                                                                                                                                    duID, e := strconv.ParseInt(c.Param("duID"), 10, 0)
                                                                                                                                                    if e != nil {
                                                                                                                                                        err = NewBadRequestError(errors.Wrap(e, "duID expects int64"))
                                                                                                                                                        break
                                                                                                                                            Severity: Minor
                                                                                                                                            Found in api/rest.go and 1 other location - About 55 mins to fix
                                                                                                                                            api/rest.go on lines 678..691

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

                                                                                                                                            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

                                                                                                                                                case http.MethodDelete:
                                                                                                                                                    publisherID, e := strconv.ParseInt(c.Param("publisherID"), 10, 0)
                                                                                                                                                    if e != nil {
                                                                                                                                                        err = NewBadRequestError(errors.Wrap(e, "publisherID expects int64"))
                                                                                                                                                        break
                                                                                                                                            Severity: Minor
                                                                                                                                            Found in api/rest.go and 1 other location - About 55 mins to fix
                                                                                                                                            api/rest.go on lines 470..483

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

                                                                                                                                            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

                                                                                                                                            func ContentUnitOriginsHandler(c *gin.Context) {
                                                                                                                                                id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                                                                                                                                                if e != nil {
                                                                                                                                                    NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                                                                                                                                                    return
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 50 mins to fix
                                                                                                                                            api/rest.go on lines 413..422
                                                                                                                                            api/rest.go on lines 772..781

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

                                                                                                                                            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

                                                                                                                                            func ContentUnitCollectionsHandler(c *gin.Context) {
                                                                                                                                                id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                                                                                                                                                if e != nil {
                                                                                                                                                    NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                                                                                                                                                    return
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 50 mins to fix
                                                                                                                                            api/rest.go on lines 489..498
                                                                                                                                            api/rest.go on lines 772..781

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

                                                                                                                                            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

                                                                                                                                            func FileStoragesHandler(c *gin.Context) {
                                                                                                                                                id, e := strconv.ParseInt(c.Param("id"), 10, 0)
                                                                                                                                                if e != nil {
                                                                                                                                                    NewBadRequestError(errors.Wrap(e, "id expects int64")).Abort(c)
                                                                                                                                                    return
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 2 other locations - About 50 mins to fix
                                                                                                                                            api/rest.go on lines 413..422
                                                                                                                                            api/rest.go on lines 489..498

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

                                                                                                                                            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

                                                                                                                                                for _, cu := range cus {
                                                                                                                                                    x := ContentUnit{ContentUnit: *cu}
                                                                                                                                                    x.I18n = make(map[string]*models.ContentUnitI18n, len(cu.R.ContentUnitI18ns))
                                                                                                                                                    for _, i18n := range cu.R.ContentUnitI18ns {
                                                                                                                                                        x.I18n[i18n.Language] = i18n
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 3 other locations - About 40 mins to fix
                                                                                                                                            api/rest.go on lines 2578..2585
                                                                                                                                            api/rest.go on lines 2635..2642
                                                                                                                                            api/rest.go on lines 2796..2803

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

                                                                                                                                            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

                                                                                                                                                for _, cu := range cus {
                                                                                                                                                    x := ContentUnit{ContentUnit: *cu}
                                                                                                                                                    x.I18n = make(map[string]*models.ContentUnitI18n, len(cu.R.ContentUnitI18ns))
                                                                                                                                                    for _, i18n := range cu.R.ContentUnitI18ns {
                                                                                                                                                        x.I18n[i18n.Language] = i18n
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 3 other locations - About 40 mins to fix
                                                                                                                                            api/rest.go on lines 1968..1975
                                                                                                                                            api/rest.go on lines 2578..2585
                                                                                                                                            api/rest.go on lines 2796..2803

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

                                                                                                                                            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

                                                                                                                                                for _, c := range cs {
                                                                                                                                                    x := Collection{Collection: *c}
                                                                                                                                                    x.I18n = make(map[string]*models.CollectionI18n, len(c.R.CollectionI18ns))
                                                                                                                                                    for _, i18n := range c.R.CollectionI18ns {
                                                                                                                                                        x.I18n[i18n.Language] = i18n
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 3 other locations - About 40 mins to fix
                                                                                                                                            api/rest.go on lines 1968..1975
                                                                                                                                            api/rest.go on lines 2635..2642
                                                                                                                                            api/rest.go on lines 2796..2803

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

                                                                                                                                            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

                                                                                                                                                for _, cu := range cus {
                                                                                                                                                    x := ContentUnit{ContentUnit: *cu}
                                                                                                                                                    x.I18n = make(map[string]*models.ContentUnitI18n, len(cu.R.ContentUnitI18ns))
                                                                                                                                                    for _, i18n := range cu.R.ContentUnitI18ns {
                                                                                                                                                        x.I18n[i18n.Language] = i18n
                                                                                                                                            Severity: Major
                                                                                                                                            Found in api/rest.go and 3 other locations - About 40 mins to fix
                                                                                                                                            api/rest.go on lines 1968..1975
                                                                                                                                            api/rest.go on lines 2578..2585
                                                                                                                                            api/rest.go on lines 2635..2642

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

                                                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                            Refactorings

                                                                                                                                            Further Reading

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

                                                                                                                                                if r.AuthorID.Valid {
                                                                                                                                                    ok, err := models.Authors(qm.Where("id = ?", r.AuthorID.Int64)).Exists(exec)
                                                                                                                                                    if err != nil {
                                                                                                                                                        return nil, NewInternalError(err)
                                                                                                                                                    }
                                                                                                                                            Severity: Minor
                                                                                                                                            Found in api/rest.go and 1 other location - About 40 mins to fix
                                                                                                                                            api/rest.go on lines 3691..3700

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

                                                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                            Refactorings

                                                                                                                                            Further Reading

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

                                                                                                                                                if s.ParentID.Valid {
                                                                                                                                                    ok, err := models.Sources(qm.Where("id = ?", s.ParentID.Int64)).Exists(exec)
                                                                                                                                                    if err != nil {
                                                                                                                                                        return nil, NewInternalError(err)
                                                                                                                                                    }
                                                                                                                                            Severity: Minor
                                                                                                                                            Found in api/rest.go and 1 other location - About 40 mins to fix
                                                                                                                                            api/rest.go on lines 3703..3712

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

                                                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                            Refactorings

                                                                                                                                            Further Reading

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

                                                                                                                                                if c.Request.Method == http.MethodGet || c.Request.Method == "" {
                                                                                                                                                    if !can(c, secureToPermission(common.SEC_PUBLIC), common.PERM_READ) {
                                                                                                                                                        NewForbiddenError().Abort(c)
                                                                                                                                                        return
                                                                                                                                                    }
                                                                                                                                            Severity: Minor
                                                                                                                                            Found in api/rest.go and 1 other location - About 30 mins to fix
                                                                                                                                            api/rest.go on lines 1057..1095

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

                                                                                                                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                                                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                                                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                                                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                                                                            Refactorings

                                                                                                                                            Further Reading

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

                                                                                                                                                if c.Request.Method == http.MethodGet || c.Request.Method == "" {
                                                                                                                                                    if !can(c, secureToPermission(common.SEC_PUBLIC), common.PERM_READ) {
                                                                                                                                                        NewForbiddenError().Abort(c)
                                                                                                                                                        return
                                                                                                                                                    }
                                                                                                                                            Severity: Minor
                                                                                                                                            Found in api/rest.go and 1 other location - About 30 mins to fix
                                                                                                                                            api/rest.go on lines 926..971

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

                                                                                                                                            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