Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Add missing licenses, and add a check #3720

Merged
merged 44 commits into from
Mar 16, 2021

Conversation

stuartmorgan
Copy link
Contributor

Adds a new CI check that all code files have a copyright+license block (and that it's one we are expecting to see).

Fixes the ~350 files (!) that did not have them. This includes all of the files in the .../example/ directories, following the example of flutter/flutter. (This does mean some manual intervention will be needed when generating new example directories in the future, but it's one-time per example.)

Also standardized some variants that used different line breaks than most of the rest of the repo (likely added since I standardized them all a while ago, but didn't add a check for at the time to enforce going forward), to simplify the checks.

Fixes flutter/flutter#77114

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • All existing and new tests are passing.

@stuartmorgan
Copy link
Contributor Author

@Hixie I added license blocks to pigeon-generated files since they didn't have a set naming scheme. I assume that's harmless to do (similar to putting it on files created by flutter create), but if it's better to filter them out by the header comment saying they are generated by pigeon I can do that instead.

// ensure that any new additions are flagged for added scrutiny in review.
// -----
// Third-party code used in url_launcher_web.
final RegExp _workivaLicenseRegex = RegExp(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should enforce that all code that doesn't have our copyright notice is in a third_party directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// All Flutter-authored code.
final RegExp _bsdLicenseRegex = RegExp(
r'^(?://|#) Use of this source code is governed by a BSD-style license',
multiLine: true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a static string rather than a pattern, to match our license block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but it would mean duplicating it for bash vs. other files. What's the issue with the pattern?

(I can put the full text in the pattern, if that's the goal.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it would be simpler, but I see what you're saying.
FWIW this is what the flutter/flutter repo does: https://github.com/flutter/flutter/blob/master/dev/bots/analyze.dart#L226-L271
It does seem shorter than what we have here and handles bash etc.

Putting the full text in the pattern would be good regardless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it stricter as a starting point; it checks the full text of both lines, without any whitespace variation allowed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have a bunch of variants (four different author phrasings, different years, a handful with commas after the year) I think the static string version would be too messy right now.

This PR did inspire me to continue my planned series of PRs to standardize this whole repo though (derailed by not having sign-off from repo owners to add AUTHORS to all plugins), so I'll pick that back up after this lands, and tighten this down as I go until it's at the point where we can use a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated to use a string (using similar code to the flutter/flutter code linked above) for the license part, but not yet the copyright part. I'll switch copyright over once I've standardized.

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a quick look at all the licenses, and they seem to be atop of their corresponding files. Made a few comments below. I think the only missing licenses in the repo now are the example/web/index.html files, but it seems those can be corrected later very easily.

@ditman
Copy link
Member

ditman commented Mar 16, 2021

(Also how come it's not running in this PR? Shouldn't this run pre-submit?)

@stuartmorgan
Copy link
Contributor Author

(Also how come it's not running in this PR? Shouldn't this run pre-submit?)

It is, it's just part of the existing "format" task. I didn't want all the overhead of another task for something that's ~instant to run, so combined it. It seemed closely linked enough to format checks conceptually to add there.

Copy link
Contributor

@mvanbeusekom mvanbeusekom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

(only thing I noticed but don't think is a problem, is that the year mentioned in the "Copyright 20xx" differs between files)

@stuartmorgan
Copy link
Contributor Author

(only thing I noticed but don't think is a problem, is that the year mentioned in the "Copyright 20xx" differs between files)

The author and year in this repo are not yet standardized. I had to abandon an initial effort to fix that a while ago, but plan to pick it up again after this.

@stuartmorgan stuartmorgan merged commit 8169973 into flutter:master Mar 16, 2021
@stuartmorgan stuartmorgan deleted the license-check branch March 16, 2021 21:50
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 16, 2021
yasargil added a commit to yasargil/plugins that referenced this pull request Mar 18, 2021
* master: (49 commits)
  Prep for alignment with Flutter analysis options (flutter#3703)
  [google_maps_flutter_platform_interface] Mark constructors as const for ids (flutter#3718)
  [image_picker] Endorse image_picker_for_web (flutter#3717)
  Add missing licenses, and add a check (flutter#3720)
  [ci] Add libgcrypt to Docker image. (flutter#3711)
  Reorder the checkboxes in the PR template (flutter#3666)
  Re-endorse connectivity_for_web (flutter#3708)
  Fix missing declaration of windows' default_package (flutter#3705)
  Typos in comments (flutter#2846)
  Skip flutter upgrade for pod linting Cirrus task (flutter#3700)
  [cross_file] Delete. (flutter#3698)
  [tool] Improve check version ci so that it enforces the version in CHANGELOG and pubspec matches. (flutter#3678)
  Streamline CI setup, and reenable macOS credits (flutter#3697)
  [video_player] fixed misleading size and aspect ratio documentation (flutter#3668)
  [image_picker] Implemented 2860 and added Unit Test to test functionality (flutter#3685)
  [shared_preferences] Fix concurrent modification of the shared preferences on Android (flutter#3684)
  [extension_google_sign_in_as_googleapis_auth] Deleted. (flutter#3694)
  Skip pod lint tests (flutter#3692)
  [Video_Player] Remove the deprecated API reference. (flutter#3669)
  [google_sign_in] fix test(flutter#3690)
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.