Comments (4)
Adding some notes from my quick research. Google's Java style guide does not instruct the style of comments to use for copyright and license information, only that it comes at the beginning of the file: https://google.github.io/styleguide/javaguide.html#s3-source-file-structure
I randomly spot-checked a half dozen Google Java projects and found:
- closure-compiler uses
/*
(example) - error-prone uses
/*
(example) - j2cl uses
/*
(example) - nomulus uses
//
(example) - flogger uses
/*
(example) - guava uses
/*
(example)
I didn't bother checking to see if projects were internally consistent with which style they used. I just checked the first java file I could find.
I also dug into the public GitHub repo dataset in BigQuery, and ran some analysis on the sample_contents table there:
Java files that contain // copyright
(accounting for spaces):
SELECT count(*) FROM `bigquery-public-data.github_repos.sample_contents`
WHERE
ENDS_WITH(sample_path, ".java")
AND REGEXP_CONTAINS(content, r'(?im)^\s*//\s*copyright')
Count: 12091
Java files that contain /* copyright
, /** copyright
or * copyright
(accounting for spaces):=
SELECT count(*) FROM `bigquery-public-data.github_repos.sample_contents`
WHERE
ENDS_WITH(sample_path, ".java")
AND REGEXP_CONTAINS(content, r'(?im)^\s*/?\*+\s*copyright')
Count 119028
So block style comments /* */
seem to be used for copyright statements in java files more often than per-line comments //
by a factor of about 10 to 1.
Given that, I'm inclined to make this change. @mco-gh, any objection?
from addlicense.
And since Kotlin was specifically mentioned in #65... block-style comments are also more common, but there is not actually enough data to draw any real conclusion (226 instances versus 7). I suspect that's because this sample_contents
table was created in 2016, before Kotlin was as popular as it is today. We'd need to query the full contents
table, which is still being updated today, to get meaningful data.
from addlicense.
I guess Scala is the other big JVM language, and one that's particularly relevant for us at Twitter.
For what it's worth, our add_license_headers.py script uses javadoc style /** */
for Scala and Kotlin, but per-line style //
for Java. 🤷🏻
from addlicense.
from addlicense.
Related Issues (20)
- use GoReleaser to build and push container images HOT 6
- use go-enry to identify generated, vendored and other types of code
- Ignore subdirectories pattern HOT 9
- Support adding license header in .txt, .patch and .tmpl files HOT 5
- Ignore doesn't work without equals sign HOT 2
- Using `//` comments for C++ header files
- malformed module path "io/fs" HOT 2
- Intermittent failure
- Include basic example of running for the first time. HOT 1
- [Proposal] Usage as module instead of CLI HOT 3
- Can a new tag be added? HOT 1
- Introduce a flag to prefer `//` over `/*...*/` HOT 1
- Copyright line should append after the SPDX identifier HOT 3
- An extra whitespace indentation for the Apache License template
- Recursive check pattern HOT 1
- (Provide option to) ignore empty files
- Feature Request: Add a version subcommand HOT 1
- Bug: Files generated by stringer are skipped HOT 4
- How to install? `go get` is deprecated
- provide fail-on-diff flag to enable checking licence headers HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from addlicense.