Skip to content

Commit 2fe3ee9

Browse files
committed
fix: use block-style comments for java, scala, kotlin
fixes #46
1 parent 9cc7ec3 commit 2fe3ee9

File tree

4 files changed

+35
-31
lines changed

4 files changed

+35
-31
lines changed

main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@ func licenseHeader(path string, tmpl *template.Template, data licenseData) ([]by
283283
switch fileExtension(path) {
284284
default:
285285
return nil, nil
286-
case ".c", ".h", ".gv":
286+
case ".c", ".h", ".gv", ".java", ".scala", ".kt", ".kts":
287287
lic, err = executeTemplate(tmpl, data, "/*", " * ", " */")
288288
case ".js", ".mjs", ".cjs", ".jsx", ".tsx", ".css", ".scss", ".sass", ".tf", ".ts":
289289
lic, err = executeTemplate(tmpl, data, "/**", " * ", " */")
290-
case ".cc", ".cpp", ".cs", ".go", ".hcl", ".hh", ".hpp", ".java", ".m", ".mm", ".proto", ".rs", ".scala", ".swift", ".dart", ".groovy", ".kt", ".kts", ".v", ".sv":
290+
case ".cc", ".cpp", ".cs", ".go", ".hcl", ".hh", ".hpp", ".m", ".mm", ".proto", ".rs", ".swift", ".dart", ".groovy", ".v", ".sv":
291291
lic, err = executeTemplate(tmpl, data, "", "// ", "")
292292
case ".py", ".sh", ".yaml", ".yml", ".dockerfile", "dockerfile", ".rb", "gemfile", ".tcl", ".bzl":
293293
lic, err = executeTemplate(tmpl, data, "", "# ", "")

main_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -303,16 +303,16 @@ func TestLicenseHeader(t *testing.T) {
303303
"",
304304
},
305305
{
306-
[]string{"f.c", "f.h", "f.gv"},
306+
[]string{"f.c", "f.h", "f.gv", "f.java", "f.scala", "f.kt", "f.kts"},
307307
"/*\n * HYS\n */\n\n",
308308
},
309309
{
310310
[]string{"f.js", "f.mjs", "f.cjs", "f.jsx", "f.tsx", "f.css", "f.scss", "f.sass", "f.tf", "f.ts"},
311311
"/**\n * HYS\n */\n\n",
312312
},
313313
{
314-
[]string{"f.cc", "f.cpp", "f.cs", "f.go", "f.hcl", "f.hh", "f.hpp", "f.java", "f.m", "f.mm", "f.proto",
315-
"f.rs", "f.scala", "f.swift", "f.dart", "f.groovy", "f.kt", "f.kts", "f.v", "f.sv", "f.php"},
314+
[]string{"f.cc", "f.cpp", "f.cs", "f.go", "f.hcl", "f.hh", "f.hpp", "f.m", "f.mm", "f.proto",
315+
"f.rs", "f.swift", "f.dart", "f.groovy", "f.v", "f.sv", "f.php"},
316316
"// HYS\n\n",
317317
},
318318
{

testdata/expected/file.java

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
// Copyright 2018 Google LLC
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
1+
/*
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
1416

1517
public class HelloWorld {
1618

testdata/expected/file.scala

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
// Copyright 2018 Google LLC
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
1+
/*
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
1416

1517
object HelloWorld {
1618
def main(args: Array[String]): Unit = {

0 commit comments

Comments
 (0)