From b761fd8070603ff9b55ba78611b17a9bb04b561a Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 3 Mar 2023 12:29:33 +0300 Subject: [PATCH] [#23] pre-commit: Add initial configuration Signed-off-by: Evgenii Stratonikov --- .gitignore | 2 +- .pre-commit-config.yaml | 19 ++++++++++++++++++ Makefile | 2 +- README.md | 8 ++++---- netmap/Tests.md | 2 +- netmap/json_tests/cbf_default.json | 2 +- netmap/json_tests/cbf_minimal.json | 2 +- netmap/json_tests/cbf_requirements.json | 2 +- netmap/json_tests/filter_complex.json | 2 +- netmap/json_tests/filter_invalid_integer.json | 2 +- netmap/json_tests/filter_simple.json | 2 +- netmap/json_tests/hrw_sort.json | 2 +- netmap/json_tests/issue213.json | 2 +- netmap/json_tests/many_selects.json | 2 +- netmap/json_tests/multiple_rep.json | 2 +- .../json_tests/multiple_rep_asymmetric.json | 2 +- netmap/json_tests/rep_only.json | 2 +- netmap/json_tests/select_no_attribute.json | 2 +- netmap/json_tests/selector_invalid.json | 2 +- netmap/json_tests/subnet.json | 2 +- netmap/parser/Query.interp | Bin 4300 -> 4301 bytes netmap/parser/QueryLexer.interp | Bin 6957 -> 6958 bytes 22 files changed, 41 insertions(+), 22 deletions(-) create mode 100644 .pre-commit-config.yaml mode change 100644 => 100755 Makefile diff --git a/.gitignore b/.gitignore index de7c370..3f5de01 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,4 @@ vendor/ # coverage coverage.txt -coverage.html \ No newline at end of file +coverage.html diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9c6f604 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,19 @@ +ci: + autofix_prs: false + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: check-merge-conflict + - id: check-json + - id: check-xml + - id: check-yaml + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + - id: end-of-file-fixer + exclude: ".key$" diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index 61bdecf..3210743 --- a/Makefile +++ b/Makefile @@ -37,4 +37,4 @@ help: @echo '' @echo ' Targets:' @echo '' - @awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort -u \ No newline at end of file + @awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort -u diff --git a/README.md b/README.md index 81c2959..e898e49 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ err := c.Dial(prmDial) if err != nil { return } - + ctx, cancel := context.WithTimeout(context.Background(), 5 * time.Second) defer cancel() @@ -98,7 +98,7 @@ Contains CRUSH-like implementation of container node selection algorithm. Releva are described in this paper http://ceur-ws.org/Vol-2344/short10.pdf . Note that it can be outdated in some details. -`netmap/json_tests` subfolder contains language-agnostic tests for selection algorithm. +`netmap/json_tests` subfolder contains language-agnostic tests for selection algorithm. ```go import ( @@ -110,7 +110,7 @@ func placementNodes(addr *object.Address, p *netmap.PlacementPolicy, frostfsNode // Convert list of nodes in FrostFS API format to the intermediate representation. nodes := netmap.NodesFromInfo(nodes) - // Create new netmap (errors are skipped for the sake of clarity). + // Create new netmap (errors are skipped for the sake of clarity). nm, _ := NewNetmap(nodes) // Calculate nodes of container. @@ -131,4 +131,4 @@ Contain simple API wrappers. Wrapper over `zap.Logger` which is used across FrostFS codebase. ### util -Utilities for working with signature-related code. \ No newline at end of file +Utilities for working with signature-related code. diff --git a/netmap/Tests.md b/netmap/Tests.md index 1b83ced..6671d09 100644 --- a/netmap/Tests.md +++ b/netmap/Tests.md @@ -15,4 +15,4 @@ Field|Description `pivot`|Optional pivot to use in container node selection. `result`|List of lists of node-indices corresponding to each replica in the placement policy. `error`|Error that should be raised for this specific test. The actual strings are used in SDK, other implementation may simply check that error has occurred. -`placement`|Optional field containing another test for selecting placement nodes for an object. Can contain `pivot`, `result` and `error` fields with the same meaning as above. Note that if `pivot` is omitted, empty value should be used. \ No newline at end of file +`placement`|Optional field containing another test for selecting placement nodes for an object. Can contain `pivot`, `result` and `error` fields with the same meaning as above. Note that if `pivot` is omitted, empty value should be used. diff --git a/netmap/json_tests/cbf_default.json b/netmap/json_tests/cbf_default.json index 73e79a5..779d37d 100644 --- a/netmap/json_tests/cbf_default.json +++ b/netmap/json_tests/cbf_default.json @@ -97,4 +97,4 @@ ] } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/cbf_minimal.json b/netmap/json_tests/cbf_minimal.json index 477e7c5..f91d096 100644 --- a/netmap/json_tests/cbf_minimal.json +++ b/netmap/json_tests/cbf_minimal.json @@ -98,4 +98,4 @@ ] } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/cbf_requirements.json b/netmap/json_tests/cbf_requirements.json index bb541d6..6c1f6ce 100644 --- a/netmap/json_tests/cbf_requirements.json +++ b/netmap/json_tests/cbf_requirements.json @@ -156,4 +156,4 @@ ] } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/filter_complex.json b/netmap/json_tests/filter_complex.json index 988f700..6f51d5d 100644 --- a/netmap/json_tests/filter_complex.json +++ b/netmap/json_tests/filter_complex.json @@ -384,4 +384,4 @@ "error": "not enough nodes" } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/filter_invalid_integer.json b/netmap/json_tests/filter_invalid_integer.json index 933f939..c2a5898 100644 --- a/netmap/json_tests/filter_invalid_integer.json +++ b/netmap/json_tests/filter_invalid_integer.json @@ -80,4 +80,4 @@ "error": "not enough nodes" } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/filter_simple.json b/netmap/json_tests/filter_simple.json index 3e3eaaf..ce12225 100644 --- a/netmap/json_tests/filter_simple.json +++ b/netmap/json_tests/filter_simple.json @@ -412,4 +412,4 @@ "error": "not enough nodes" } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/hrw_sort.json b/netmap/json_tests/hrw_sort.json index 521a852..fb20dfc 100644 --- a/netmap/json_tests/hrw_sort.json +++ b/netmap/json_tests/hrw_sort.json @@ -162,4 +162,4 @@ } } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/issue213.json b/netmap/json_tests/issue213.json index 513e39d..f029931 100644 --- a/netmap/json_tests/issue213.json +++ b/netmap/json_tests/issue213.json @@ -106,4 +106,4 @@ ] } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/many_selects.json b/netmap/json_tests/many_selects.json index f0bb8a2..cbe96b1 100644 --- a/netmap/json_tests/many_selects.json +++ b/netmap/json_tests/many_selects.json @@ -189,4 +189,4 @@ ] } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/multiple_rep.json b/netmap/json_tests/multiple_rep.json index 8abb6cd..c10d86e 100644 --- a/netmap/json_tests/multiple_rep.json +++ b/netmap/json_tests/multiple_rep.json @@ -92,4 +92,4 @@ ] } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/multiple_rep_asymmetric.json b/netmap/json_tests/multiple_rep_asymmetric.json index 0e6e796..4bd356b 100644 --- a/netmap/json_tests/multiple_rep_asymmetric.json +++ b/netmap/json_tests/multiple_rep_asymmetric.json @@ -329,4 +329,4 @@ ] } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/rep_only.json b/netmap/json_tests/rep_only.json index b69ba5e..b985a56 100644 --- a/netmap/json_tests/rep_only.json +++ b/netmap/json_tests/rep_only.json @@ -110,4 +110,4 @@ "error": "not enough nodes" } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/select_no_attribute.json b/netmap/json_tests/select_no_attribute.json index 2dd3931..a9a30a5 100644 --- a/netmap/json_tests/select_no_attribute.json +++ b/netmap/json_tests/select_no_attribute.json @@ -114,4 +114,4 @@ ] } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/selector_invalid.json b/netmap/json_tests/selector_invalid.json index 9d709fd..b0d3416 100644 --- a/netmap/json_tests/selector_invalid.json +++ b/netmap/json_tests/selector_invalid.json @@ -101,4 +101,4 @@ "error": "not enough nodes" } } -} \ No newline at end of file +} diff --git a/netmap/json_tests/subnet.json b/netmap/json_tests/subnet.json index b75dccb..fdefe1b 100644 --- a/netmap/json_tests/subnet.json +++ b/netmap/json_tests/subnet.json @@ -251,4 +251,4 @@ "error": "not enough nodes" } } -} \ No newline at end of file +} diff --git a/netmap/parser/Query.interp b/netmap/parser/Query.interp index 298ddaebe73fcd27e8b70021fc7ba1a1add1ab2d..59aff7186a2ad8d4538ab08b1de06877b7e7c953 100644 GIT binary patch delta 9 QcmX@3cvf-4839Hv02O)za{vGU delta 7 OcmX@Bct&x<836zepaW