github-vet / github-vet/rangeloop-pointer-findings
chengyanfeng/egg_backend: controller/timeTracker.go; 73 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [chengyanfeng/egg_backend](https://www.github.com/chengyanfeng/egg_backend) at [controller/timeTracker.go](https://github.com/chengyanfeng/egg_backend/blob/9fb11e689aa379cd43647e0a082e275e48bda15b/controller/timeTracker.go#L13-L85)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.
>
[Click here to see the code in its original context.](https://github.com/chengyanfeng/egg_backend/blob/9fb11e689aa379cd43647e0a082e275e48bda15b/controller/timeTracker.go#L13-L85)
Click here to show the 73 line(s) of Go which triggered the analyzer.
```go
for _, v := range HenList {
//所有的鸡全部更为饥饿状态
v.State = 1
models.DB.Model(&v).Update("state")
feed := models.Feed{}
feed.HenId = v.ID
//检查昨天是否喂养
feed.CreateTimeDay = util.GetYesDayTime()
//如果喂养,下蛋
if !models.DB.NewRecord(feed) {
//鸡舍
HenHouse := models.HenHouse{}
HenHouse.UserID = v.UserID
models.DB.First(&HenHouse)
//用户资产表
userProperty := models.UserProperty{}
userProperty.UserID = v.UserID
models.DB.First(&userProperty)
//查询喂养记录
models.DB.First(&feed)
//判断鸡的类型
switch v.HenType {
case 1:
models.FreeHee(&feed, &userProperty, &v, &HenHouse)
break
case 2:
models.DarlingHee(&feed, &userProperty, &v, &HenHouse)
break
case 3:
models.GoldHee(&feed, &userProperty, &v, &HenHouse)
break
case 4:
models.LitileHee(&feed, &userProperty, &v, &HenHouse)
break
}
} else {
//没有喂养公鸡生命值-1
v.Lifes = v.Lifes - 1
//公鸡生命值减去1
models.DB.Save(&v)
}
//查看今天的是否喂养
feedif := models.Feed{}
feed.HenId = v.ID
feed.UserId = v.UserID
if !models.DB.NewRecord(feedif) {
//更改鸡的状态
models.ChangeChilckType(v.ID, 2)
}
//如果是托管的鸡
if v.Deposit == 1 {
//查看当天有没有喂养
goldFeed := models.Feed{}
count := 0
models.DB.Model(&goldFeed).Where("UserId=? AND HenId=? AND CreateTimeDay=?", v.UserID, v.ID, util.ToInt(util.GetCurDayTime())).Count(&count)
if count == 0 {
//主动喂食料
UserProperty := models.UserProperty{}
UserProperty.UserID = v.UserID
models.DB.First(&UserProperty)
//检查是否有还有食料
flag := models.CheckFeed(&UserProperty)
if flag > 0 {
models.DepositFeed(flag, &v)
}
}
}
}
```
Click here to show extra information the analyzer produced.
```
No path was found through the callgraph that could lead to a function which writes a pointer argument.
No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.
root signature {Model 1} was not found in the callgraph; reference was passed directly to third-party code
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 9fb11e689aa379cd43647e0a082e275e48bda15b
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.