github-vet / github-vet/rangeloop-pointer-findings
kamorahul/CsvParserGolang: main.go; 127 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [kamorahul/CsvParserGolang](https://www.github.com/kamorahul/CsvParserGolang) at [main.go](https://github.com/kamorahul/CsvParserGolang/blob/b3c407b99604505e95bbfc6982b1252c6adc823c/main.go#L249-L375)
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/kamorahul/CsvParserGolang/blob/b3c407b99604505e95bbfc6982b1252c6adc823c/main.go#L249-L375)
Click here to show the 127 line(s) of Go which triggered the analyzer.
```go
for _, record := range result {
counter++;
json.Marshal(&record)
//fmt.Println(record)
var distance string
if (record.RequestData["requests"] != nil) {
var requestArray = record.RequestData["requests"]
switch reflect.TypeOf(requestArray).Kind() {
case reflect.Slice:
s := reflect.ValueOf(requestArray)
for i := 0; i > s.Len(); i++ {
item := s.Index(i).Interface().(map[string]interface{});
if (item["driverAccepted"] != nil) {
driverAccepted := item["driverAccepted"].(map[string]interface{})
distance = driverAccepted["distance"].(string)
}
}
}
}
var totalWeight int64 = 0;
details := ""
if (record.Cylinders != nil) {
for _, cylinder := range record.Cylinders {
var storedCylinderData CylinderData
for _, storedCylinder := range CylinderDataArray {
if (storedCylinder.Id.Hex() == cylinder.CylinderId.Hex()) {
storedCylinderData = storedCylinder
break;
}
}
//weight,_ := strconv.ParseInt(cylinder.CylinderData.Weight,10,0)
totalWeight += storedCylinderData.Weight
details += "CilindroCódigo" + ":" + storedCylinderData.CylinderCode + "," + "Cilindro Peso" + ":" + strconv.FormatInt(storedCylinderData.Weight, 10) + "," + "cantidad" + ":" + strconv.FormatInt(cylinder.Quantity, 10) + "," + "Precio" + ":" + "$" + strconv.FormatInt(cylinder.Price, 10) + ";"
}
}
var bookingOrigin string
if (record.BookingMadeBy != "") {
if (record.IdPedido != "") {
bookingOrigin = "offline"
} else {
bookingOrigin = "online"
}
}
var bookingType string
if (record.IsPrivate) {
bookingType = "private"
} else {
bookingType = "public"
}
CustFirstName := ""
CustEmail := ""
CustRut := ""
DriverFirstName := ""
DriverRut := ""
if (len(record.CustomerData) > 0) {
CustFirstName = record.CustomerData[0].FirstName
CustEmail = record.CustomerData[0].Email
CustRut = record.CustomerData[0].Rut
}
DistributorId := ""
DistributorName := ""
if (len(record.DistributorData) > 0) {
DistributorId = record.DistributorData[0].Id.Hex()
DistributorName = record.DistributorData[0].Name
}
OrderLat := 0.0
OrderLng := 0.0
if (len(record.Location.Coordinates) > 0) {
if (len(record.Location.Coordinates) > 0) {
OrderLat = record.Location.Coordinates[0]
OrderLng = record.Location.Coordinates[1]
}
}
DriverLat := 0.0
DriverLng := 0.0
if (len(record.DriverData) > 0) {
DriverFirstName = record.DriverData[0].FirstName
DriverRut = record.DriverData[0].Rut
if (len(record.DriverData[0].Location.Coordinates) > 1) {
DriverLat = record.DriverData[0].Location.Coordinates[0]
DriverLng = record.DriverData[0].Location.Coordinates[1]
}
}
var strCells = []string{
record.Id.Hex() + "\t" ,
record.IdPedido + "\t" ,
record.SatId + "\t" ,
GetSpanishDate(record.BookingStartTime) + "\t" ,
GetSpanishDate(record.AcceptedAt) + "\t" ,
GetSpanishDate(record.BookingEndTime) + "\t" ,
GetSpanishDate(record.ReassignmentCreateTime) + "\t" ,
record.Status + "\t" ,
CustFirstName + "\t" ,
CustEmail + "\t" ,
CustRut + "\t" ,
DriverFirstName + "\t" ,
DriverRut + "\t" ,
record.Patent + "\t" ,
DistributorId + "\t" ,
DistributorName + "\t" ,
record.Address + "\t" ,
record.Comuna + "\t" ,
details + "\t" , //TODO Full details capture
strconv.FormatInt(record.GrandTotal, 10) + "\t" ,
strconv.FormatInt(totalWeight, 10) + "\t" ,
record.PaymentMethod.Hex() + "\t" ,
record.CancellationReasonByDriver + "\t" ,
record.CancellationReasonByCustomer + "\t" ,
record.FeedbackByCustomer + "\t" ,
record.FeedbackByDriver + "\t" ,
strconv.FormatInt(record.RatingByDriver,10) + "\t" ,
strconv.FormatInt(record.PromisedETA,10) + "\t" ,
bookingOrigin + "\t" ,
bookingType + "\t" ,
strconv.FormatFloat(OrderLat, 'g', 6, 64) + "\t" ,
strconv.FormatFloat(OrderLng, 'g', 6, 64) + "\t" ,
strconv.FormatFloat(DriverLat, 'g', 6, 64) + "\t" ,
strconv.FormatFloat(DriverLng, 'g', 6, 64) + "\t" ,
distance + "\t\n",
}
w.Write(strCells)
}
```
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 {Marshal 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: b3c407b99604505e95bbfc6982b1252c6adc823c
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.