Coder Social home page Coder Social logo

Comments (4)

willnorris avatar willnorris commented on May 27, 2024

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:

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.

willnorris avatar willnorris commented on May 27, 2024

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.

willnorris avatar willnorris commented on May 27, 2024

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.

mco-gh avatar mco-gh commented on May 27, 2024

from addlicense.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.