Showing 704 of 1,135 total issues
Function queueFile
has 5 return statements (exceeds 4 allowed). Open
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 {
Function nameBySourceUID
has 5 return statements (exceeds 4 allowed). Open
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")
}
Function associateUnitToCollection
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
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,
- Read upRead up
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
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
Function DownloadUrl
has 5 return statements (exceeds 4 allowed). Open
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")
Method TestDBManager.InitTestDB
has 5 return statements (exceeds 4 allowed). Open
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()
Method TestDBManager.runMigrations
has 5 return statements (exceeds 4 allowed). Open
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
Function PersonsListHandler
has 5 return statements (exceeds 4 allowed). Open
Open
func PersonsListHandler(c *gin.Context) {
var err *HttpError
var resp interface{}
switch c.Request.Method {
Function UpdateFileProperties
has 5 return statements (exceeds 4 allowed). Open
Open
func UpdateFileProperties(exec boil.Executor, file *models.File, props map[string]interface{}) error {
if len(props) == 0 {
return nil
}
Function removeDescendants
has 5 return statements (exceeds 4 allowed). Open
Open
func removeDescendants(exec boil.Executor, file *models.File) ([]events.Event, error) {
evnts := make([]events.Event, 0)
if file.RemovedAt.Valid {
return evnts, nil
}
Function handleContentUnitAddFiles
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
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()
- Read upRead up
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
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()
Function handleGetSources
has 5 return statements (exceeds 4 allowed). Open
Open
func handleGetSources(exec boil.Executor, r SourcesRequest) (*SourcesResponse, *HttpError) {
mods := make([]qm.QueryMod, 0)
// count query
var total int64
Function getUniqSourceAndCUUID
has 5 return statements (exceeds 4 allowed). Open
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))
Function handleCreateContentUnit
has 5 return statements (exceeds 4 allowed). Open
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()
}
Function appendSearchTermFilterMods
has 5 return statements (exceeds 4 allowed). Open
Open
func appendSearchTermFilterMods(exec boil.Executor, mods *[]qm.QueryMod, f SearchTermFilter, entityType int) error {
if f.Query == "" {
return nil
}
Function CreateCollection
has 5 return statements (exceeds 4 allowed). Open
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)
}
Function attachCollection
has 5 return statements (exceeds 4 allowed). Open
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
Function TagsHandler
has 5 return statements (exceeds 4 allowed). Open
Open
func TagsHandler(c *gin.Context) {
var err *HttpError
var resp interface{}
if c.Request.Method == http.MethodGet || c.Request.Method == "" {
Function handleCollectionContentUnitsPosition
has 5 return statements (exceeds 4 allowed). Open
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"),