Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix deepsource identified issues #19

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea/
vendor/*
coverage.txt
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ dist: xenial

sudo: false

branches:
only:
- master

install:
- go get -u github.com/golang/protobuf/protoc-gen-go
- curl -L https://github.com/protocolbuffers/protobuf/releases/download/v3.9.1/protoc-3.9.1-linux-x86_64.zip -o /tmp/protoc.zip
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ unit-tests: deps
integration-tests: deps
@echo "Running Integration Tests"
go test -v ./... -mod=vendor -race -tags=integration

clean:
# cleans the test cache
go clean -testcache
# cleans the go modules cache
go clean --modcache
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[![Build Status](https://travis-ci.org/Sheshagiri/go-protobuf-cloud-datastore-entity-translator.svg?branch=master)](https://travis-ci.org/Sheshagiri/go-protobuf-cloud-datastore-entity-translator)
[![codecov](https://codecov.io/gh/Sheshagiri/go-protobuf-cloud-datastore-entity-translator/branch/master/graph/badge.svg)](https://codecov.io/gh/Sheshagiri/go-protobuf-cloud-datastore-entity-translator)

[![DeepSource](https://static.deepsource.io/deepsource-badge-light-mini.svg)](https://deepsource.io/gh/Sheshagiri/go-protobuf-cloud-datastore-entity-translator/?ref=repository-badge)

# Background

Expand Down
6 changes: 3 additions & 3 deletions datastore-translator/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func ProtoMessageToDatastoreEntity(src proto.Message, snakeCase bool, excludeFro
excludeFromIndexExt := "[exclude_from_index]:true "
var excludeIndex string
// use the Extension name is passed else derive it dynamically
if excludeFromIndexName != nil && len(excludeFromIndexName) > 0 {
if len(excludeFromIndexName) > 0 {
excludeFromIndexExt = fmt.Sprintf("[%s]:true ", excludeFromIndexName[0])
excludeIndex = excludeFromIndexName[0]
} else {
Expand All @@ -41,7 +41,7 @@ func ProtoMessageToDatastoreEntity(src proto.Message, snakeCase bool, excludeFro
}
}

excludeFields := make(map[string]string, 0)
excludeFields := make(map[string]string)
for _, fd := range md.GetField() {
if fd.GetOptions() != nil {
excludeFields[fd.GetName()] = fd.GetOptions().String()
Expand Down Expand Up @@ -301,7 +301,7 @@ func fromStructValueToDatastoreValue(v *structpb.Value) *datastore.Value {
}
case *structpb.Value_StructValue:
structValue := v.GetStructValue()
properties := make(map[string]*datastore.Value, 0)
properties := make(map[string]*datastore.Value)
for key, value := range structValue.GetFields() {
properties[key] = fromStructValueToDatastoreValue(value)
}
Expand Down