Skip to content

Commit

Permalink
Formatting the code and ensuring it conforms to the linter's requirem…
Browse files Browse the repository at this point in the history
…ents.
  • Loading branch information
Falokut committed Mar 28, 2024
1 parent f5f0fde commit 6e627d0
Show file tree
Hide file tree
Showing 32 changed files with 1,033 additions and 789 deletions.
1 change: 0 additions & 1 deletion .Dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ Makefile
*.md
*.txt
*.proto
**/movies_db/
24 changes: 24 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This workflow will tests a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.4'

- name: Test
run: go test -v ./...
55 changes: 55 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: golangci-lint
on:
push:
branches:
- master
- main
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@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22.0"
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: latest

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

# Optional: golangci-lint command line arguments.
#
# Note: By default, the `.golangci.yml` file should be at the root of the repository.
# The location of the configuration file can be changed by using `--config=`
# args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0

# 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 all caching functionality will be completely disabled,
# takes precedence over all other caching options.
# skip-cache: true

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

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

# Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
# install-mode: "goinstall"
160 changes: 160 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
linters-settings:
dupl:
threshold: 100
funlen:
lines: -1 # the number of lines (code + empty lines) is not a right metric and leads to code without empty line or one-liner.
statements: 75
goconst:
min-len: 2
min-occurrences: 3
gocritic:
enabled-tags:
- diagnostic
- experimental
- performance
- style
disabled-checks:
- dupImport # https://github.com/go-critic/go-critic/issues/845
- ifElseChain
- octalLiteral
- whyNoLint
- ptrToRefParam
gocyclo:
min-complexity: 15
gofmt:
rewrite-rules:
- pattern: "interface{}"
replacement: "any"
gomnd:
# don't include the "operation" and "assign"
checks:
- argument
- case
- condition
- return
ignored-numbers:
- "0"
- "1"
- "2"
- "3"
ignored-functions:
- strings.SplitN
govet:
settings:
printf:
funcs:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
enable:
- nilness
- shadow
errorlint:
asserts: false
lll:
line-length: 140
misspell:
locale: US
nolintlint:
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
revive:
rules:
- name: unexported-return
disabled: true
- name: unused-parameter
maligned:
suggest-new: true

linters:
disable-all: true
enable:
- bodyclose
- dogsled
- dupl
- errcheck
- errorlint
- exportloopref
- funlen
- gocheckcompilerdirectives
- gochecknoinits
- goconst
- gocritic
- gocyclo
- gofmt
- gomnd
- goprintffuncname
- gosimple
- govet
- ineffassign
- lll
- misspell
- noctx
- nolintlint
- revive
- staticcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- whitespace

# don't enable:
# - asciicheck
# - gochecknoglobals
# - gocognit
# - godot
# - godox
# - goerr113
# - nestif
# - prealloc
# - testpackage
# - wsl

issues:
exclude:
- "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked"
- "exported (type|method|function) (.+) should have comment or be unexported"
- "ST1000: at least one file in a package should have a package comment"
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-rules:
- path: _test\.go
linters:
- gomnd
- path: pkg/golinters/errcheck.go
linters: [staticcheck]
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
- path: pkg/commands/run.go
linters: [staticcheck]
text: "SA1019: lsc.Errcheck.Exclude is deprecated: use ExcludeFunctions instead"
- path: pkg/commands/run.go
linters: [staticcheck]
text: "SA1019: c.cfg.Run.ShowStats is deprecated: use Output.ShowStats instead."

- path: pkg/golinters/gofumpt.go
linters: [staticcheck]
text: "SA1019: settings.LangVersion is deprecated: use the global `run.go` instead."
- path: pkg/golinters/staticcheck_common.go
linters: [staticcheck]
text: "SA1019: settings.GoVersion is deprecated: use the global `run.go` instead."
- path: pkg/lint/lintersdb/manager.go
linters: [staticcheck]
text: "SA1019: (.+).(GoVersion|LangVersion) is deprecated: use the global `run.go` instead."

- path: pkg/golinters/unused.go
linters: [gocritic]
text: "rangeValCopy: each iteration copies 160 bytes \\(consider pointers or indexing\\)"
- path: test/(fix|linters)_test.go
linters: [gocritic]
text: "string `gocritic.go` has 3 occurrences, make it a constant"

run:
timeout: 5m
skip-dirs:
- test/testdata_etc # test files
- internal/cache # extracted from Go code
- internal/renameio # extracted from Go code
- internal/robustio # extracted from Go code
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# Cinema service
[![Go Report Card](https://goreportcard.com/badge/github.com/Falokut/cinema_orders_service)](https://goreportcard.com/report/github.com/Falokut/cinema_orders_service)
[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat-square)](https://pkg.go.dev/github.com/Falokut/cinema_orders_service)
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/Falokut/cinema_orders_service)
[![Go](https://github.com/Falokut/cinema_orders_service/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/Falokut/cinema_orders_service/actions/workflows/go.yml) ![](https://changkun.de/urlstat?mode=github&repo=Falokut/cinema_orders_service)
[![License](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
---

# Content

Expand Down Expand Up @@ -60,8 +66,8 @@ if supported values is empty, then any type values are supported
|refund_sleep_time|payment_service||time.Duration with positive duration|the time after which the order status changes TO REFUNDED|[supported values](#timeduration-yaml-supported-values)|
|addr|profiles_service|PROFILES_SERVICE_ADDR|string|address of the profiles service|all valid addresses formatted like host:port or ip-address:port|
|secure_config|profiles_service||nested yml configuration [secure config](#secure-connection-config)|||
|addr|cinema_service|CINEMA_SERVICE_ADDR|string|address of the profiles service|all valid addresses formatted like host:port or ip-address:port|
|secure_config|cinema_service||nested yml configuration [secure config](#secure-connection-config)|||
|addr|cinema_orders_service|CINEMA_SERVICE_ADDR|string|address of the profiles service|all valid addresses formatted like host:port or ip-address:port|
|secure_config|cinema_orders_service||nested yml configuration [secure config](#secure-connection-config)|||


### time.Duration yaml supported values
Expand Down
Loading

0 comments on commit 6e627d0

Please sign in to comment.