Skip to content
This repository has been archived by the owner on Jun 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #10 from goark/debug
Browse files Browse the repository at this point in the history
Fix warnings by lint
  • Loading branch information
spiegel-im-spiegel authored Jul 24, 2022
2 parents e097a19 + 9381542 commit b2ce165
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 59 deletions.
82 changes: 37 additions & 45 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,44 @@ on:
- cron: '0 20 * * 0'

jobs:
analyze:
name: Analyze
CodeQL-Build:
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['go']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
permissions:
# required for all workflows
security-events: write

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# only required for workflows in private repositories
actions: read
contents: read

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
# Override language selection by uncommenting this and choosing your languages
with:
languages: go

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below).
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following
# three lines and modify them (or add more) to build your code if your
# project uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
30 changes: 26 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,43 @@ on:
branches:
- master
pull_request:

permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: ^1.18
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
args: --enable gosec

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
- name: testing
run: go test -shuffle on ./...
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tasks:
cmds:
- go mod verify
- go test -shuffle on ./...
- docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.45.2 golangci-lint run --enable gosec --timeout 3m0s ./...
- docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.47.2 golangci-lint run --enable gosec --timeout 3m0s ./...
sources:
- ./go.mod
- '**/*.go'
Expand Down
Binary file modified dependency.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module github.com/goark/cov19data
go 1.18

require (
github.com/goark/csvdata v0.5.0
github.com/goark/csvdata v0.5.3
github.com/goark/errs v1.1.0
github.com/goark/fetch v0.3.0
golang.org/x/text v0.3.7
)
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
github.com/goark/csvdata v0.5.0 h1:k5oQXmXdMce6+i6mLytffAa44b22KduCA52A14cXe+4=
github.com/goark/csvdata v0.5.0/go.mod h1:qVxMNmElo3nT5KjMz0HjOygu5JrEk0VUCrOpoOJmrR4=
github.com/goark/csvdata v0.5.3 h1:rab4H0lu67EPks4F9ekcy2DWwTFH5z8gxnp77es91G0=
github.com/goark/csvdata v0.5.3/go.mod h1:3bm237hGfTaOr2IReP2bbDSmEdosrkAse0iNoUQztvA=
github.com/goark/errs v1.1.0 h1:FKnyw4LVyRADIjM8Nj0Up6r0/y5cfADvZAd1E+tthXE=
github.com/goark/errs v1.1.0/go.mod h1:TtaPEoadm2mzqzfXdkkfpN2xuniCFm2q4JH+c1qzaqw=
github.com/goark/fetch v0.3.0 h1:2m32EGOLBi99RzI5urFfmv5++CMqfenVw7NH8z/lbX8=
github.com/goark/fetch v0.3.0/go.mod h1:sqDdPbbHeIjDVeHrgvzhHpkUr8X9pVC9DgJoVwU02x0=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
2 changes: 1 addition & 1 deletion histogram/histogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ func NewList(p values.Period, step int) ([]*HistData, values.Period) {
to := next
next = to.AddDay(-step)
from := next.AddDay(1)
start = from
histList = append(histList, New(values.NewPeriod(from, to), 0, 0))
if values.NewPeriod(from, to).Contains(p.Start) {
break
}
start = from
}
sort.Slice(histList, func(i, j int) bool {
return histList[i].Period.End.Before(histList[j].Period.End)
Expand Down
3 changes: 1 addition & 2 deletions import.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ func (i *Import) Histogram(period values.Period, step int, opts ...filter.Filter
if step < 1 {
return nil, errs.Wrap(os.ErrInvalid, errs.WithContext("period", period.String()), errs.WithContext("step", step))
}
histList, p := histogram.NewList(period, step)
histList, _ := histogram.NewList(period, step)
if len(histList) == 0 {
return nil, errs.Wrap(os.ErrInvalid, errs.WithContext("period", period.String()), errs.WithContext("step", step))
}
period = p
filter := filter.New(opts...)
for {
record, err := i.next()
Expand Down
3 changes: 1 addition & 2 deletions tokyo/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ func (i *Import) Histogram(period values.Period, step int, opts ...filter.Filter
if step < 1 {
return nil, errs.Wrap(os.ErrInvalid, errs.WithContext("period", period.String()), errs.WithContext("step", step))
}
histList, p := histogram.NewList(period, step)
histList, _ := histogram.NewList(period, step)
if len(histList) == 0 {
return nil, errs.Wrap(os.ErrInvalid, errs.WithContext("period", period.String()), errs.WithContext("step", step))
}
period = p
filter := filter.New(opts...)
for {
record, err := i.next()
Expand Down
5 changes: 4 additions & 1 deletion values/prefecture-jp.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"fmt"
"strconv"
"strings"

"golang.org/x/text/cases"
"golang.org/x/text/language"
)

//PrefJpCode is prefecture code in Japan
Expand Down Expand Up @@ -157,7 +160,7 @@ func (pc PrefJpCode) NameLower() string {
}

func (pc PrefJpCode) Title() string {
return strings.Title(pc.NameLower())
return cases.Title(language.Und, cases.NoLower).String(pc.NameLower())
}

//UnmarshalJSON method returns result of Unmarshal for json.Unmarshal().
Expand Down

0 comments on commit b2ce165

Please sign in to comment.