Skip to content

Commit

Permalink
Add license and go report
Browse files Browse the repository at this point in the history
Signed-off-by: Dušan Borovčanin <[email protected]>
  • Loading branch information
dborovcanin committed Dec 13, 2019
1 parent b8c5bef commit 7cb7855
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ jobs:
with:
go-version: 1.13
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: test
run: |
go test -v -race -tags test -coverprofile=profile.out -covermode=atomic ./...
- name: Upload coverage to Codecov
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# SenML

[![coverage][cov-badge]][cov-url]
[![go report card][grc-badge]][grc-url]
[![license][license]](LICENSE)

This repository contains a lightweight implementation of [RFC 8428 Sensor Measurement Lists (SenML)](https://tools.ietf.org/html/rfc8428)

Expand All @@ -23,3 +25,6 @@ All SenML Records in a Pack must have the same version number. This is typically

[cov-badge]: https://codecov.io/gh/mainflux/senml/branch/master/graph/badge.svg
[cov-url]: https://codecov.io/gh/mainflux/senml
[grc-badge]: https://goreportcard.com/badge/github.com/mainflux/senml
[grc-url]: https://goreportcard.com/report/github.com/mainflux/senml
[license]: https://img.shields.io/badge/license-Apache%20v2.0-blue.svg
21 changes: 14 additions & 7 deletions senml.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,21 @@ func Validate(p Pack) error {
if valCnt < 1 {
return ErrNoValues
}
l := name[0]
if (l == '-') || (l == ':') || (l == '.') || (l == '/') || (l == '_') {
return ErrBadChar
if err := validateName(name); err != nil {
return err
}
for _, l := range name {
if (l < 'a' || l > 'z') && (l < 'A' || l > 'Z') && (l < '0' || l > '9') && (l != '-') && (l != ':') && (l != '.') && (l != '/') && (l != '_') {
return ErrBadChar
}
}
return nil
}

func validateName(name string) error {
l := name[0]
if (l == '-') || (l == ':') || (l == '.') || (l == '/') || (l == '_') {
return ErrBadChar
}
for _, l := range name {
if (l < 'a' || l > 'z') && (l < 'A' || l > 'Z') && (l < '0' || l > '9') && (l != '-') && (l != ':') && (l != '.') && (l != '/') && (l != '_') {
return ErrBadChar
}
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions senml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var (
func pack() senml.Pack {
return senml.Pack{
Records: []senml.Record{
senml.Record{
{
BaseName: "base-name",
BaseTime: 100,
BaseUnit: "base-unit",
Expand All @@ -42,7 +42,7 @@ func pack() senml.Pack {
Value: &value,
Sum: &sum,
},
senml.Record{
{
BaseName: "base-name",
BaseTime: 100,
BaseUnit: "base-unit",
Expand Down

0 comments on commit 7cb7855

Please sign in to comment.