RFC: build/analysis: add commentwrap
This adds a Go analyzer which limits the length of comment lines to 80
characters.
Rationale:
Monogon currently follows gofmt style. Gofmt in itself is already quite
opinionated, but one thing it explicitly does not check for is maximum
line length.
This implements a limit for the maximum length of a comment line in Go
source within Monogon. It explicitly does not limit code line length, as
these can be handled much more easily by soft reflows.
The tool used, github.com/corverroos/commentwrap, will now be
automatically ran by our nogo pass, and prevent any line of commnets
within Go to be longer than 80 characters, with the exception of:
- cgo/generate directives
- TODOs
- indented comments (eg. sample code or long URLs)
Downsides:
1. We have to reformat the entire codebase. CR/67 does this.
2. We end up with a bulk Git commit that will pollute Git history. A
followup CR attempts to resolve this by using Git's ignoreRevsFile
functionality.
3. There's currently no integration with IntelliJ and no way to
automatically reformat code. If this RFC gets approved, a follow up
CR will be created that adds integration/automation to make this
easier to work against.
Open questions:
1. Is 80 characters the right limit? I, personally, quite like it, but
am willing to compromise on line length.
Change-Id: I063d64596ca5ef038a8426c6b9f806b65c18451e
Reviewed-on: https://review.monogon.dev/c/monogon/+/66
Reviewed-by: Leopold Schabel <leo@nexantic.com>
diff --git a/third_party/go/repositories.bzl b/third_party/go/repositories.bzl
index f5fd825..bdb7601 100644
--- a/third_party/go/repositories.bzl
+++ b/third_party/go/repositories.bzl
@@ -475,6 +475,20 @@
],
)
go_repository(
+ name = "com_github_corverroos_commentwrap",
+ importpath = "github.com/corverroos/commentwrap",
+ version = "v0.0.0-20191204065359-2926638be44c",
+ sum = "h1:toeMwwechJKH0iwOoGJLZK6x42Ba9si+816KxqmgFc8=",
+ patches = [
+ "//third_party/go/patches:commentwrap-tool-library.patch",
+ ],
+ patch_args = ["-p1"],
+ build_extra_args = [
+ "-go_naming_convention=go_default_library",
+ "-go_naming_convention_external=go_default_library",
+ ],
+ )
+ go_repository(
name = "com_github_cosiner_argv",
importpath = "github.com/cosiner/argv",
version = "v0.0.0-20170225145430-13bacc38a0a5",
@@ -1571,6 +1585,20 @@
],
)
go_repository(
+ name = "com_github_muesli_reflow",
+ importpath = "github.com/muesli/reflow",
+ version = "v0.0.0-20191128061954-86f094cbed14",
+ sum = "h1:99aDTygRy9yEwggATz+ZLrDFRsjRog5BqbAfsr47Ztw=",
+ patches = [
+ "//third_party/go/patches:reflow-tool-library.patch",
+ ],
+ patch_args = ["-p1"],
+ build_extra_args = [
+ "-go_naming_convention=go_default_library",
+ "-go_naming_convention_external=go_default_library",
+ ],
+ )
+ go_repository(
name = "com_github_munnerz_goautoneg",
importpath = "github.com/munnerz/goautoneg",
version = "v0.0.0-20191010083416-a7dc8b61c822",