aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy/servo_tidy/licenseck.py
diff options
context:
space:
mode:
authoredunham <edunham@mozilla.com>2016-04-19 13:57:09 -0700
committerUK992 <urbankrajnc92@gmail.com>2016-08-12 13:32:09 +0200
commit48ace17b5419a9795a13bded286e113e79d56905 (patch)
treebc78a198ae1129c8c16979b868fba2b2634d0eb1 /python/tidy/servo_tidy/licenseck.py
parent1f4dd8765fe06784f052765f63f3e4869faf8164 (diff)
downloadservo-48ace17b5419a9795a13bded286e113e79d56905.tar.gz
servo-48ace17b5419a9795a13bded286e113e79d56905.zip
Improve tidy's license validation logic
fixes https://github.com/servo/servo/issues/10716 I took the lazy way out and hardcoded the size of block we examine for licenses. fixes https://github.com/servo/servo/issues/10719 Includes tests for new functionality.
Diffstat (limited to 'python/tidy/servo_tidy/licenseck.py')
-rw-r--r--python/tidy/servo_tidy/licenseck.py114
1 files changed, 23 insertions, 91 deletions
diff --git a/python/tidy/servo_tidy/licenseck.py b/python/tidy/servo_tidy/licenseck.py
index 3a17f1fdf04..a9fe9077f21 100644
--- a/python/tidy/servo_tidy/licenseck.py
+++ b/python/tidy/servo_tidy/licenseck.py
@@ -7,97 +7,29 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.
-
-# These licenses are valid for use in Servo
-licenses = [
-
-"""\
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-""",
-
-"""\
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-""",
-
-"""\
-#!/usr/bin/env bash
-
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-""",
-
-"""\
-#!/usr/bin/env python
-
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-""",
-
-"""\
-#!/usr/bin/env python3
-
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-""",
-
-"""\
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this
-// file, You can obtain one at http://mozilla.org/MPL/2.0/.
-""",
-
-"""\
-// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-""",
-
-"""\
-# Copyright 2013 The Servo Project Developers. See the COPYRIGHT
-# file at the top-level directory of this distribution.
-#
-# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-# option. This file may not be copied, modified, or distributed
-# except according to those terms.
-""",
-
-"""\
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-""",
-
-"""\
-// Copyright 2012-2014 The Rust Project Developers.
-// See http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-""",
-] # noqa: Indicate to flake8 that we do not want to check indentation here
+# when wrapped to 80 chars, the longest license is 10 lines.
+# TODO actually grab whatever commented block is before the second blank line
+# of the file instead of hard-coding this.
+MAX_LICENSE_LINESPAN = 12
+
+MPL = """\
+This Source Code Form is subject to the terms of the Mozilla Public \
+License, v. 2.0. If a copy of the MPL was not distributed with this \
+file, You can obtain one at http://mozilla.org/MPL/2.0/.\
+"""
+
+APACHE = """\
+Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or \
+http://www.apache.org/licenses/LICENSE-2.0> or the MIT license \
+<LICENSE-MIT or http://opensource.org/licenses/MIT>, at your \
+option. This file may not be copied, modified, or distributed \
+except according to those terms.\
+"""
+
+COPYRIGHT = [
+ "See the COPYRIGHT file at the top-level directory of this distribution",
+ "See http://rust-lang.org/COPYRIGHT",
+]
# The valid licenses, in the form we'd expect to see them in a Cargo.toml file.
licenses_toml = [