Skip to content

Commit

Permalink
feat: initial commit (#0)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrop committed Sep 15, 2023
0 parents commit eb16725
Show file tree
Hide file tree
Showing 17 changed files with 2,736 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .codacy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
engines:
duplication:
minTokenMatch: 50
exclude_paths:
- "**/*_test.go"
revive:
exclude_paths:
- "**/mock_*_test.go"
29 changes: 29 additions & 0 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Go
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ^1.21

- name: Build and tests
env:
CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
run: make --file=Makefile.base --trace all

- name: Send coverage report
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: ./build/test-all.cover

- name: Release and publish
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: |-
make --file=Makefile.base --trace release && \
make --file=Makefile.base --trace publish
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.project

build
run

mock_*_test.go
12 changes: 12 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[extend]
useDefault = true

[allowlist]
description = "Allowlist false positives"
regexTarget = "match"
regexes = [
# Mark CDP build secret_version as false positive since it does not contain a secret.
'''(?i)(?:secret_version:)(?:['|\"|\s]{0,5})([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:['|\"|\n|\r|\s]{0,5}|$)''',
# Mark api-id or api_id or x-api-id as false positive since they are uuids that are used in OAS and stacksets to track apis.
'''(?i)(?:api[_-]id(?:['|\"|\s|:]{0,5}))(?:['|\"|\s]{0,5})([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?:['|\"|\n|\r|\s]{0,5}|$)'''
]
189 changes: 189 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
run:
# Timeout for analysis, e.g. 30s, 5m.
# Default: 1m
timeout: 3m

linters:
# Placeholder for dynamically enabled linters.

issues:
# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3 (we recommend 10-20)
max-same-issues: 10

# Use default exclusions for common false positives as defined in
# https://golangci-lint.run/usage/false-positives/#default-exclusions
# Default: true (we use false to sync behavior with Codacy)
exclude-use-default: false

# Defining manually exclusions that make sense.
exclude-rules:
# Exclude go:generate directives from line length checking.
- source: "^//\\s*go:generate\\s"
linters: [ lll, revive ]
# Exclude magic number in time setups and bit shifting.
- source: "[0-9]+ ?\\* ?time\\.|(<<|>>) ?[0-9]+|[0-9]+ ?(<<|>>)"
linters: [ gomnd ]
# Exclude certain standards from being applied in test.
- path: "_test\\.go"
linters: [ bodyclose, contextcheck, dupl, funlen, goconst, gosec, noctx,
goerr113, wrapcheck ]

# Exclude error return value check because of too many false positives.
- text: 'Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked'
linters: [ errcheck ]
# Exclude certain revive standards from being applied in tests.
- path: "_test\\.go"
text: "^(max-public-structs|function-length|cognitive-complexity):"
linters: [ revive ]
# Exclude dots in unfinished thoughts.
- source: "(noinspection|TODO)"
linters: [ godot ]


# This contains only configs which differ from defaults. For other configs see
# https://github.com/golangci/golangci-lint/blob/master/.golangci.reference.yml
linters-settings:
cyclop:
# The maximal code complexity to report.
# Default: 10 (we allow up to 20)
max-complexity: 20
# The maximal average package complexity.
# If it's higher than 0.0 (float) the check is enabled
# Default: 0.0 (we recommend 10.0 as baseline)
package-average: 10.0

gocognit:
# Minimal code complexity to report.
# Default: 30 (we recommend 10-20)
min-complexity: 20

lll:
# Max line length, lines longer will be reported. '\t' is counted as 1
# character by default, and can be changed with the tab-width option.
# Default: 120 (we recommend 80 but compromise at 100)
line-length: 100
# Tab width in spaces.
# Default: 1 (go uses 4 for visualization)
tab-width: 4

nolintlint:
# Exclude following linters from requiring an explanation.
# Default: [] (but some lll does not need explanation)
allow-no-explanation: [ lll, wrapcheck ]
# Enable to require an explanation of nonzero length after each nolint
# directive.
# Default: false
require-explanation: true
# Enable to require nolint directives to mention the specific linter being
# suppressed.
# Default: false
require-specific: true

govet:
# Enable all analyzers.
# Default: false
enable-all: true
# Disable analyzers by name.
# Run `go tool vet help` to see all analyzers.
# Default: []
disable:
- fieldalignment # too strict
- shadow # too strict to always work around

gosec:
# To specify a set of rules to explicitly exclude.
# Available rules: https://github.com/securego/gosec#available-rules
# Default: [] (issues are fixed)
excludes: [ G105, G307 ]

gocritic:
# Settings passed to gocritic. The settings key is the name of a supported
# gocritic checker. The list of supported checkers can be find in
# https://go-critic.github.io/overview.
settings:
captLocal:
# Whether to restrict checker to params only.
# Default: true
paramsOnly: false
underef:
# Whether to skip (*x).method() calls where x is a pointer receiver.
# Default: true
skipRecvDeref: false

tenv:
# The option `all` will run the linter on the whole test files regardless
# of method signatures. Otherwise, only methods that take `*testing.T`,
# `*testing.B`, and `testing.TB` as arguments are checked.
# Default: false
all: true

revive:
# Enable all available rules.
# Default: false
enable-all-rules: true
# When set to false, ignores files with "GENERATED" header, similar to golint.
# See https://github.com/mgechev/revive#available-rules for details.
# Default: false
ignore-generated-header: true
# Sets the default severity.
# See https://github.com/mgechev/revive#configuration
# Default: warning
severity: error

rules:
# No need to enforce a file header.
- name: file-header
disabled: true
# Reports on each file in a package.
- name: package-comments
disabled: true
# Reports on comments not matching the name as first word.
- name: exported
disabled: true
# No need to exclude import shadowing.
- name: import-shadowing
disabled: true
# Fails to exclude nolint directives from reporting.
- name: comment-spacings
disabled: true
# Fails to disable writers that actually cannot return errors.
- name: unhandled-error
disabled: true
# Fails to restrict sufficiently in switches with numeric values.
- name: add-constant
disabled: true
# Rule prevents intentional usage of similar variable names.
- name: flag-parameter
disabled: true
# Rule prevents intentional usage of similar private method names.
- name: confusing-naming
disabled: true

# Enables a more experienced cyclomatic complexity (we enabled a lot of
# rules to counter-act the complexity trap).
- name: cyclomatic
arguments: [20]
# Enables a more experienced cognitive complexity (we enabled a lot of
# rules to counter-act the complexity trap).
- name: cognitive-complexity
arguments: [20]
# Limit line-length to increase readability.
- name: line-length-limit
arguments: [100]
# We are a bit more relaxed with function length consistent with funlen.
- name: function-length
arguments: [40, 60]
# Limit arguments of functions to the maximum understandable value.
- name: argument-limit
arguments: [6]
# Limit results of functions to the maximum understandable value.
- name: function-result-limit
arguments: [4]
# Raise the limit a bit to allow more complex package models.
- name: max-public-structs
arguments: [8]
# I do not know what I'm doing here...
- name: banned-characters
arguments: ["Ω", "Σ", "σ"]
35 changes: 35 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Default state for all rules
default: true

# MD012/no-multiple-blanks - Multiple consecutive blank lines
MD012:
# Consecutive blank lines
maximum: 3

# MD013/line-length - Line length
MD013:
# Number of characters
line_length: 80
# Number of characters for headings
heading_line_length: 80
# Number of characters for code blocks
code_block_line_length: 80
# Include code blocks
code_blocks: true
# Include tables
tables: true
# Include headings
headings: true
# Include headings
headers: true
# Strict length checking
strict: true
# Stern length checking
stern: false

# MD022/blanks-around-headings/blanks-around-headers - Headings should be surrounded by blank lines
MD022:
# Blank lines above heading
lines_above: 2
# Blank lines below heading
lines_below: 1
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Tronje Krop

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit eb16725

Please sign in to comment.