Bnei-Baruch/mdb

View on GitHub

Showing 704 of 1,135 total issues

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

func queueFile(id int64, sha1 string) error {
    url := "http://files.kabbalahmedia.info/api/v1/transcode"

    resp, err := utils.HttpPostJson(url, TranscodeRequest{Sha1: sha1, Format: "mp4"})
    if err != nil {
Severity: Major
Found in batch/convert.go - About 35 mins to fix

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

    func nameBySourceUID(exec boil.Executor, uid string) (map[string]string, error) {
        s, err := FindSourceByUID(exec, uid)
        if err != nil {
            return nil, errors.Wrapf(err, "Find source in DB")
        }
    Severity: Major
    Found in api/autoname.go - About 35 mins to fix

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

      func associateUnitToCollection(exec boil.Executor, cu *models.ContentUnit, c *models.Collection, metadata CITMetadata) error {
          log.Infof("Associating unit and collection [c-cu]=[%d-%d]", c.ID, cu.ID)
      
          ccu := &models.CollectionsContentUnit{
              CollectionID:  c.ID,
      Severity: Minor
      Found in api/metadata_processor.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

      Method RegexpReplacer.updateDB has 5 return statements (exceeds 4 allowed).
      Open

      func (a *RegexpReplacer) updateDB(iteration int) error {
          log.Infof("Start replace on iteration %d", iteration)
          rows, err := queries.Raw(a.DB, fmt.Sprintf(`Select %s, id FROM %s ORDER BY id`, a.ColName, a.TableName)).Query()
          if err != nil {
              return err
      Severity: Major
      Found in batch/regexp_replace.go - About 35 mins to fix

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

        func DownloadUrl(url string, path string) error {
            // create output file
            output, err := os.Create(path)
            if err != nil {
                return errors.Wrap(err, "Create output file")
        Severity: Major
        Found in utils/http.go - About 35 mins to fix

          Method TestDBManager.InitTestDB has 5 return statements (exceeds 4 allowed).
          Open

          func (m *TestDBManager) InitTestDB() error {
              m.testDB = fmt.Sprintf("test_%s", strings.ToLower(GenerateName(10)))
              fmt.Println("Initializing test DB: ", m.testDB)
          
              m.initConfig()
          Severity: Major
          Found in utils/test_utils.go - About 35 mins to fix

            Method TestDBManager.runMigrations has 5 return statements (exceeds 4 allowed).
            Open

            func (m *TestDBManager) runMigrations(db *sql.DB) error {
                var visit = func(path string, f os.FileInfo, err error) error {
                    match, _ := regexp.MatchString(".*\\.sql$", path)
                    if !match {
                        return nil
            Severity: Major
            Found in utils/test_utils.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 UpdateFileProperties has 5 return statements (exceeds 4 allowed).
                Open

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

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

                  func removeDescendants(exec boil.Executor, file *models.File) ([]events.Event, error) {
                      evnts := make([]events.Event, 0)
                      if file.RemovedAt.Valid {
                          return evnts, nil
                      }
                  Severity: Major
                  Found in api/handlers.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 CreateCollection has 5 return statements (exceeds 4 allowed).
                              Open

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

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

                                func attachCollection(tx boil.Executor, c *models.Collection, cu *models.ContentUnit, cus []int64) error {
                                    var prevPos int64
                                
                                    if err := queries.Raw(fmt.Sprintf(LAST_POSITION_BY_C_SQL, c.ID)).QueryRow(tx).Scan(&prevPos); err != nil {
                                        return err
                                Severity: Major
                                Found in api/auto_series.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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language