From 15455ab5930f73a9273ef24c4a98014e98b977a8 Mon Sep 17 00:00:00 2001 From: Arve Knudsen Date: Tue, 24 Mar 2020 13:50:05 +0100 Subject: [PATCH] CircleCI: Run golangci-lint in two batches (#23021) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * CircleCI: Run golangci-lint in two batches Signed-off-by: Arve Knudsen * CircleCI: Fix typo Signed-off-by: Arve Knudsen * Chore: adds fallback value to time series class * Chore: changes fallback value from null to empty string in FilterInput component * Update public/app/core/time_series2.ts Co-Authored-By: Hugo Häggmark * Chore: updates || to ?? operators Co-authored-by: Lukas Siatka Co-authored-by: Hugo Häggmark --- .circleci/config.yml | 6 ++++-- .../app/core/components/FilterInput/FilterInput.tsx | 4 ++-- public/app/core/time_series2.ts | 4 ++-- scripts/go/configs/ci/.golangci.yml | 12 ++++++++++++ 4 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 scripts/go/configs/ci/.golangci.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 54c4545212f..a327cd009e4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -734,8 +734,10 @@ jobs: name: Lint Go command: | go vet ./pkg/... - # Adjust golangci-lint concurrency since it can run out of memory - golangci-lint run -v -j 2 --config scripts/go/configs/.golangci.yml ./pkg/... + golangci-lint run -v -j 2 --config scripts/go/configs/ci/.golangci.yml -E deadcode -E gofmt \ + -E gosimple -E ineffassign -E structcheck -E typecheck ./pkg/... + golangci-lint run -v -j 2 --config scripts/go/configs/ci/.golangci.yml -E unconvert -E unused \ + -E varcheck -E goconst -E errcheck -E staticcheck ./pkg/... ./scripts/go/bin/revive -formatter stylish -config ./scripts/go/configs/revive.toml ./pkg/... ./scripts/go/bin/revive -formatter stylish ./pkg/services/alerting/... ./scripts/go/bin/gosec -quiet -exclude=G104,G107,G108,G201,G202,G204,G301,G304,G401,G402,G501 \ diff --git a/public/app/core/components/FilterInput/FilterInput.tsx b/public/app/core/components/FilterInput/FilterInput.tsx index 5505166befa..0bf09eb494f 100644 --- a/public/app/core/components/FilterInput/FilterInput.tsx +++ b/public/app/core/components/FilterInput/FilterInput.tsx @@ -15,9 +15,9 @@ export const FilterInput = forwardRef((props, ref) => ( ref={ref} type="text" className={props.inputClassName} - value={unEscapeStringFromRegex(props.value)} + value={props.value ? unEscapeStringFromRegex(props.value) : ''} onChange={event => props.onChange(escapeStringForRegex(event.target.value))} - placeholder={props.placeholder ? props.placeholder : null} + placeholder={props.placeholder ?? ''} /> diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts index e09c59ee062..1452863b84f 100644 --- a/public/app/core/time_series2.ts +++ b/public/app/core/time_series2.ts @@ -344,8 +344,8 @@ export default class TimeSeries { updateLegendValues(formater: ValueFormatter, decimals: DecimalCount, scaledDecimals: DecimalCount) { this.valueFormater = formater; - this.decimals = decimals; - this.scaledDecimals = scaledDecimals; + this.decimals = decimals ?? 0; + this.scaledDecimals = scaledDecimals ?? 0; } formatValue(value: number) { diff --git a/scripts/go/configs/ci/.golangci.yml b/scripts/go/configs/ci/.golangci.yml new file mode 100644 index 00000000000..7e5a604532b --- /dev/null +++ b/scripts/go/configs/ci/.golangci.yml @@ -0,0 +1,12 @@ +run: + timeout: 10m + +linters: + disable-all: true + +linters-settings: + goconst: + # minimal length of string constant, 3 by default + min-len: 5 + # minimal occurrences count to trigger, 3 by default + min-occurrences: 5