From 2fe3ee94479d08be985a84861de4e6b06a1c7208 Mon Sep 17 00:00:00 2001 From: Will Norris Date: Tue, 10 Aug 2021 10:26:12 -0700 Subject: [PATCH] fix: use block-style comments for java, scala, kotlin fixes #46 --- main.go | 4 ++-- main_test.go | 6 +++--- testdata/expected/file.java | 28 +++++++++++++++------------- testdata/expected/file.scala | 28 +++++++++++++++------------- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/main.go b/main.go index 105a006..8bd07aa 100644 --- a/main.go +++ b/main.go @@ -283,11 +283,11 @@ func licenseHeader(path string, tmpl *template.Template, data licenseData) ([]by switch fileExtension(path) { default: return nil, nil - case ".c", ".h", ".gv": + case ".c", ".h", ".gv", ".java", ".scala", ".kt", ".kts": lic, err = executeTemplate(tmpl, data, "/*", " * ", " */") case ".js", ".mjs", ".cjs", ".jsx", ".tsx", ".css", ".scss", ".sass", ".tf", ".ts": lic, err = executeTemplate(tmpl, data, "/**", " * ", " */") - case ".cc", ".cpp", ".cs", ".go", ".hcl", ".hh", ".hpp", ".java", ".m", ".mm", ".proto", ".rs", ".scala", ".swift", ".dart", ".groovy", ".kt", ".kts", ".v", ".sv": + case ".cc", ".cpp", ".cs", ".go", ".hcl", ".hh", ".hpp", ".m", ".mm", ".proto", ".rs", ".swift", ".dart", ".groovy", ".v", ".sv": lic, err = executeTemplate(tmpl, data, "", "// ", "") case ".py", ".sh", ".yaml", ".yml", ".dockerfile", "dockerfile", ".rb", "gemfile", ".tcl", ".bzl": lic, err = executeTemplate(tmpl, data, "", "# ", "") diff --git a/main_test.go b/main_test.go index 94998d5..76340db 100644 --- a/main_test.go +++ b/main_test.go @@ -303,7 +303,7 @@ func TestLicenseHeader(t *testing.T) { "", }, { - []string{"f.c", "f.h", "f.gv"}, + []string{"f.c", "f.h", "f.gv", "f.java", "f.scala", "f.kt", "f.kts"}, "/*\n * HYS\n */\n\n", }, { @@ -311,8 +311,8 @@ func TestLicenseHeader(t *testing.T) { "/**\n * HYS\n */\n\n", }, { - []string{"f.cc", "f.cpp", "f.cs", "f.go", "f.hcl", "f.hh", "f.hpp", "f.java", "f.m", "f.mm", "f.proto", - "f.rs", "f.scala", "f.swift", "f.dart", "f.groovy", "f.kt", "f.kts", "f.v", "f.sv", "f.php"}, + []string{"f.cc", "f.cpp", "f.cs", "f.go", "f.hcl", "f.hh", "f.hpp", "f.m", "f.mm", "f.proto", + "f.rs", "f.swift", "f.dart", "f.groovy", "f.v", "f.sv", "f.php"}, "// HYS\n\n", }, { diff --git a/testdata/expected/file.java b/testdata/expected/file.java index f7bfa34..5bdca95 100644 --- a/testdata/expected/file.java +++ b/testdata/expected/file.java @@ -1,16 +1,18 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ public class HelloWorld { diff --git a/testdata/expected/file.scala b/testdata/expected/file.scala index 5b2d659..a21b2b3 100644 --- a/testdata/expected/file.scala +++ b/testdata/expected/file.scala @@ -1,16 +1,18 @@ -// Copyright 2018 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Copyright 2018 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ object HelloWorld { def main(args: Array[String]): Unit = {