diff options
Diffstat (limited to '')
90 files changed, 836 insertions, 0 deletions
diff --git a/tools/lint/test/files/android-format/Bad.java b/tools/lint/test/files/android-format/Bad.java new file mode 100644 index 0000000000..13aa5d49d5 --- /dev/null +++ b/tools/lint/test/files/android-format/Bad.java @@ -0,0 +1,8 @@ +package org.mozilla.geckoview; + +import java.util.Arrays; + +public class Bad { + public static void main() { + } +} diff --git a/tools/lint/test/files/android-format/Main.kt b/tools/lint/test/files/android-format/Main.kt new file mode 100644 index 0000000000..a172cf71ee --- /dev/null +++ b/tools/lint/test/files/android-format/Main.kt @@ -0,0 +1,7 @@ +package org.mozilla.geckoview + +import java.util.Arrays; + +fun main() { +println("Hello") +} diff --git a/tools/lint/test/files/android-format/build.gradle b/tools/lint/test/files/android-format/build.gradle new file mode 100644 index 0000000000..6d2aff6d60 --- /dev/null +++ b/tools/lint/test/files/android-format/build.gradle @@ -0,0 +1 @@ +buildDir "${topobjdir}/gradle/build/tools/lint/test/files/android-format" diff --git a/tools/lint/test/files/black/bad.py b/tools/lint/test/files/black/bad.py new file mode 100644 index 0000000000..0a50df4dd9 --- /dev/null +++ b/tools/lint/test/files/black/bad.py @@ -0,0 +1,6 @@ +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +print ( + "test" + ) diff --git a/tools/lint/test/files/black/invalid.py b/tools/lint/test/files/black/invalid.py new file mode 100644 index 0000000000..079ecbad30 --- /dev/null +++ b/tools/lint/test/files/black/invalid.py @@ -0,0 +1,4 @@ +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +print( diff --git a/tools/lint/test/files/clang-format/bad/bad.cpp b/tools/lint/test/files/clang-format/bad/bad.cpp new file mode 100644 index 0000000000..f08a83f795 --- /dev/null +++ b/tools/lint/test/files/clang-format/bad/bad.cpp @@ -0,0 +1,6 @@ +int main ( ) { + +return 0; + + +} diff --git a/tools/lint/test/files/clang-format/bad/bad2.c b/tools/lint/test/files/clang-format/bad/bad2.c new file mode 100644 index 0000000000..9792e85071 --- /dev/null +++ b/tools/lint/test/files/clang-format/bad/bad2.c @@ -0,0 +1,8 @@ +#include "bad2.h" + + +int bad2() { + int a =2; + return a; + +} diff --git a/tools/lint/test/files/clang-format/bad/bad2.h b/tools/lint/test/files/clang-format/bad/bad2.h new file mode 100644 index 0000000000..a35d49d7e7 --- /dev/null +++ b/tools/lint/test/files/clang-format/bad/bad2.h @@ -0,0 +1 @@ +int bad2(void ); diff --git a/tools/lint/test/files/clang-format/bad/good.cpp b/tools/lint/test/files/clang-format/bad/good.cpp new file mode 100644 index 0000000000..76e8197013 --- /dev/null +++ b/tools/lint/test/files/clang-format/bad/good.cpp @@ -0,0 +1 @@ +int main() { return 0; } diff --git a/tools/lint/test/files/clang-format/good/foo.cpp b/tools/lint/test/files/clang-format/good/foo.cpp new file mode 100644 index 0000000000..76e8197013 --- /dev/null +++ b/tools/lint/test/files/clang-format/good/foo.cpp @@ -0,0 +1 @@ +int main() { return 0; } diff --git a/tools/lint/test/files/clippy/test1/Cargo.toml b/tools/lint/test/files/clippy/test1/Cargo.toml new file mode 100644 index 0000000000..92d5072eca --- /dev/null +++ b/tools/lint/test/files/clippy/test1/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "hello_world" # the name of the package +version = "0.1.0" # the current version, obeying semver +authors = ["Alice <a@example.com>", "Bob <b@example.com>"] + +[[bin]] +name ="good" +path = "good.rs" + +[[bin]] +name ="bad" +path = "bad.rs" + +[[bin]] +name ="bad2" +path = "bad2.rs" + diff --git a/tools/lint/test/files/clippy/test1/bad.rs b/tools/lint/test/files/clippy/test1/bad.rs new file mode 100644 index 0000000000..c403fba603 --- /dev/null +++ b/tools/lint/test/files/clippy/test1/bad.rs @@ -0,0 +1,14 @@ +fn main() { + // Statements here are executed when the compiled binary is called + + // Print text to the console + println!("Hello World!"); + // Clippy detects this as a swap and considers this as an error + let mut a=1; + let mut b=1; + + a = b; + b = a; + + +} diff --git a/tools/lint/test/files/clippy/test1/bad2.rs b/tools/lint/test/files/clippy/test1/bad2.rs new file mode 100644 index 0000000000..bf488bbe72 --- /dev/null +++ b/tools/lint/test/files/clippy/test1/bad2.rs @@ -0,0 +1,14 @@ +fn main() { + // Statements here are executed when the compiled binary is called + + // Print text to the console + println!("Hello World!"); + let mut a; + let mut b=1; + let mut vec = vec![1, 2]; + + for x in 5..10 - 5 { + a = x; + } + + } diff --git a/tools/lint/test/files/clippy/test1/good.rs b/tools/lint/test/files/clippy/test1/good.rs new file mode 100644 index 0000000000..9bcaee67b7 --- /dev/null +++ b/tools/lint/test/files/clippy/test1/good.rs @@ -0,0 +1,6 @@ +fn main() { + // Statements here are executed when the compiled binary is called + + // Print text to the console + println!("Hello World!"); +} diff --git a/tools/lint/test/files/clippy/test2/Cargo.lock b/tools/lint/test/files/clippy/test2/Cargo.lock new file mode 100644 index 0000000000..6b2bc69eeb --- /dev/null +++ b/tools/lint/test/files/clippy/test2/Cargo.lock @@ -0,0 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "hello_world_2" +version = "0.2.0" diff --git a/tools/lint/test/files/clippy/test2/Cargo.toml b/tools/lint/test/files/clippy/test2/Cargo.toml new file mode 100644 index 0000000000..b0ac992088 --- /dev/null +++ b/tools/lint/test/files/clippy/test2/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "hello_world_2" # the name of the package +version = "0.2.0" # the current version, obeying semver +authors = ["Alice <a@example.com>", "Bob <b@example.com>"] + +[[bin]] +name = "fake_lib1" +path = "src/bad_1.rs" diff --git a/tools/lint/test/files/clippy/test2/src/bad_1.rs b/tools/lint/test/files/clippy/test2/src/bad_1.rs new file mode 100644 index 0000000000..2fe0630202 --- /dev/null +++ b/tools/lint/test/files/clippy/test2/src/bad_1.rs @@ -0,0 +1,15 @@ +mod bad_2; + +fn main() { + // Statements here are executed when the compiled binary is called + + // Print text to the console + println!("Hello World!"); + // Clippy detects this as a swap and considers this as an error + let mut a=1; + let mut b=1; + + a = b; + b = a; + +} diff --git a/tools/lint/test/files/clippy/test2/src/bad_2.rs b/tools/lint/test/files/clippy/test2/src/bad_2.rs new file mode 100644 index 0000000000..f77de330b4 --- /dev/null +++ b/tools/lint/test/files/clippy/test2/src/bad_2.rs @@ -0,0 +1,17 @@ +fn foo() { + // Statements here are executed when the compiled binary is called + + // Print text to the console + println!("Hello World!"); + let mut a; + let mut b=1; + let mut vec = Vec::new(); + vec.push(1); + vec.push(2); + + + for x in 5..10 - 5 { + a = x; + } + + } diff --git a/tools/lint/test/files/codespell/ignore.rst b/tools/lint/test/files/codespell/ignore.rst new file mode 100644 index 0000000000..1371d07054 --- /dev/null +++ b/tools/lint/test/files/codespell/ignore.rst @@ -0,0 +1,5 @@ +This is a file with some typos and informations. +But also testing false positive like optin (because this isn't always option) +or stuff related to our coding style like: +aparent (aParent). +but detects mistakes like mozila diff --git a/tools/lint/test/files/eslint/good.js b/tools/lint/test/files/eslint/good.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tools/lint/test/files/eslint/good.js diff --git a/tools/lint/test/files/eslint/import/bad_import.js b/tools/lint/test/files/eslint/import/bad_import.js new file mode 100644 index 0000000000..e2a8ec8de1 --- /dev/null +++ b/tools/lint/test/files/eslint/import/bad_import.js @@ -0,0 +1 @@ +/* import-globals-from notpresent/notpresent.js */ diff --git a/tools/lint/test/files/eslint/nolint/foo.txt b/tools/lint/test/files/eslint/nolint/foo.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tools/lint/test/files/eslint/nolint/foo.txt diff --git a/tools/lint/test/files/eslint/subdir/bad.js b/tools/lint/test/files/eslint/subdir/bad.js new file mode 100644 index 0000000000..9d2dd18f39 --- /dev/null +++ b/tools/lint/test/files/eslint/subdir/bad.js @@ -0,0 +1,2 @@ +// Missing semicolon +let foo = "bar" diff --git a/tools/lint/test/files/file-perm/maybe-shebang/bad.js b/tools/lint/test/files/file-perm/maybe-shebang/bad.js new file mode 100755 index 0000000000..1a0b4c5fd6 --- /dev/null +++ b/tools/lint/test/files/file-perm/maybe-shebang/bad.js @@ -0,0 +1,2 @@ +# Nothing too + diff --git a/tools/lint/test/files/file-perm/maybe-shebang/good.js b/tools/lint/test/files/file-perm/maybe-shebang/good.js new file mode 100755 index 0000000000..8149c0d4f3 --- /dev/null +++ b/tools/lint/test/files/file-perm/maybe-shebang/good.js @@ -0,0 +1,5 @@ +#!/usr/bin/env node + + +# Nothing + diff --git a/tools/lint/test/files/file-perm/no-shebang/bad-shebang.c b/tools/lint/test/files/file-perm/no-shebang/bad-shebang.c new file mode 100755 index 0000000000..7151678efa --- /dev/null +++ b/tools/lint/test/files/file-perm/no-shebang/bad-shebang.c @@ -0,0 +1,2 @@ +#!/bin/bash +int main() { return 0; } diff --git a/tools/lint/test/files/file-perm/no-shebang/bad.c b/tools/lint/test/files/file-perm/no-shebang/bad.c new file mode 100755 index 0000000000..76e8197013 --- /dev/null +++ b/tools/lint/test/files/file-perm/no-shebang/bad.c @@ -0,0 +1 @@ +int main() { return 0; } diff --git a/tools/lint/test/files/file-perm/no-shebang/bad.png b/tools/lint/test/files/file-perm/no-shebang/bad.png Binary files differnew file mode 100755 index 0000000000..db3a5fda7e --- /dev/null +++ b/tools/lint/test/files/file-perm/no-shebang/bad.png diff --git a/tools/lint/test/files/file-perm/no-shebang/good.c b/tools/lint/test/files/file-perm/no-shebang/good.c new file mode 100644 index 0000000000..76e8197013 --- /dev/null +++ b/tools/lint/test/files/file-perm/no-shebang/good.c @@ -0,0 +1 @@ +int main() { return 0; } diff --git a/tools/lint/test/files/file-whitespace/bad-newline.c b/tools/lint/test/files/file-whitespace/bad-newline.c new file mode 100644 index 0000000000..3746a0add3 --- /dev/null +++ b/tools/lint/test/files/file-whitespace/bad-newline.c @@ -0,0 +1,3 @@ +int main() { return 0; } + +
\ No newline at end of file diff --git a/tools/lint/test/files/file-whitespace/bad-windows.c b/tools/lint/test/files/file-whitespace/bad-windows.c new file mode 100644 index 0000000000..70d4c697b9 --- /dev/null +++ b/tools/lint/test/files/file-whitespace/bad-windows.c @@ -0,0 +1,3 @@ +int main(){
+ return 42;
+}
diff --git a/tools/lint/test/files/file-whitespace/bad.c b/tools/lint/test/files/file-whitespace/bad.c new file mode 100644 index 0000000000..4309b1f55d --- /dev/null +++ b/tools/lint/test/files/file-whitespace/bad.c @@ -0,0 +1,3 @@ +int main() { +return 0; +} diff --git a/tools/lint/test/files/file-whitespace/bad.js b/tools/lint/test/files/file-whitespace/bad.js new file mode 100644 index 0000000000..3441696ef1 --- /dev/null +++ b/tools/lint/test/files/file-whitespace/bad.js @@ -0,0 +1,3 @@ +# Nothing too + + diff --git a/tools/lint/test/files/file-whitespace/good.c b/tools/lint/test/files/file-whitespace/good.c new file mode 100644 index 0000000000..76e8197013 --- /dev/null +++ b/tools/lint/test/files/file-whitespace/good.c @@ -0,0 +1 @@ +int main() { return 0; } diff --git a/tools/lint/test/files/file-whitespace/good.js b/tools/lint/test/files/file-whitespace/good.js new file mode 100644 index 0000000000..8149c0d4f3 --- /dev/null +++ b/tools/lint/test/files/file-whitespace/good.js @@ -0,0 +1,5 @@ +#!/usr/bin/env node + + +# Nothing + diff --git a/tools/lint/test/files/flake8/.flake8 b/tools/lint/test/files/flake8/.flake8 new file mode 100644 index 0000000000..1933432319 --- /dev/null +++ b/tools/lint/test/files/flake8/.flake8 @@ -0,0 +1,4 @@ +[flake8] +max-line-length = 100 +exclude = + subdir/exclude, diff --git a/tools/lint/test/files/flake8/bad.py b/tools/lint/test/files/flake8/bad.py new file mode 100644 index 0000000000..9d9751c7eb --- /dev/null +++ b/tools/lint/test/files/flake8/bad.py @@ -0,0 +1,5 @@ +# Unused import +import distutils + +print("This is a line that is over 80 characters but under 100. It shouldn't fail.") +print("This is a line that is over not only 80, but 100 characters. It should most certainly cause a failure.") diff --git a/tools/lint/test/files/flake8/custom/.flake8 b/tools/lint/test/files/flake8/custom/.flake8 new file mode 100644 index 0000000000..cfe68833f2 --- /dev/null +++ b/tools/lint/test/files/flake8/custom/.flake8 @@ -0,0 +1,4 @@ +[flake8] +max-line-length=110 +ignore= + F401 diff --git a/tools/lint/test/files/flake8/custom/good.py b/tools/lint/test/files/flake8/custom/good.py new file mode 100644 index 0000000000..7f9121a2ba --- /dev/null +++ b/tools/lint/test/files/flake8/custom/good.py @@ -0,0 +1,5 @@ +# Unused import +import distutils + +print("This is a line that is over 80 characters but under 100. It shouldn't fail.") +print("This is a line that is over not only 80, but 100 characters. It should also not cause a failure.") diff --git a/tools/lint/test/files/flake8/ext/bad.configure b/tools/lint/test/files/flake8/ext/bad.configure new file mode 100644 index 0000000000..8214ebb3c0 --- /dev/null +++ b/tools/lint/test/files/flake8/ext/bad.configure @@ -0,0 +1,2 @@ +# unused import +import os diff --git a/tools/lint/test/files/flake8/subdir/exclude/bad.py b/tools/lint/test/files/flake8/subdir/exclude/bad.py new file mode 100644 index 0000000000..9d9751c7eb --- /dev/null +++ b/tools/lint/test/files/flake8/subdir/exclude/bad.py @@ -0,0 +1,5 @@ +# Unused import +import distutils + +print("This is a line that is over 80 characters but under 100. It shouldn't fail.") +print("This is a line that is over not only 80, but 100 characters. It should most certainly cause a failure.") diff --git a/tools/lint/test/files/flake8/subdir/exclude/exclude_subdir/bad.py b/tools/lint/test/files/flake8/subdir/exclude/exclude_subdir/bad.py new file mode 100644 index 0000000000..9d9751c7eb --- /dev/null +++ b/tools/lint/test/files/flake8/subdir/exclude/exclude_subdir/bad.py @@ -0,0 +1,5 @@ +# Unused import +import distutils + +print("This is a line that is over 80 characters but under 100. It shouldn't fail.") +print("This is a line that is over not only 80, but 100 characters. It should most certainly cause a failure.") diff --git a/tools/lint/test/files/fluent-lint/bad.ftl b/tools/lint/test/files/fluent-lint/bad.ftl new file mode 100644 index 0000000000..ebc0e1a602 --- /dev/null +++ b/tools/lint/test/files/fluent-lint/bad.ftl @@ -0,0 +1,44 @@ +Blah-blah = Uppercase letters in identifiers are not permitted. +blah-blah = This is a legal identifier. +blah_blah = Underscores in identifiers are not permitted. + +bad-apostrophe-1 = The bee's knees +bad-apostrophe-end-1 = The bees' knees +bad-apostrophe-2 = The bee‘s knees +bad-single-quote = 'The bee’s knees' +ok-apostrophe = The bee’s knees +ok-single-quote = ‘The bee’s knees’ +bad-double-quote = "The bee’s knees" +good-double-quote = “The bee’s knees” +bad-ellipsis = The bee’s knees... +good-ellipsis = The bee’s knees… + +embedded-tag = Read more about <a data-l10n-name="privacy-policy"> our privacy policy </a>. +bad-embedded-tag = Read more about <a data-l10n-name="privacy-policy"> our 'privacy' policy </a>. + +Invalid_Id = This identifier is in the exclusions file and will not cause an error. + +good-has-attributes = + .accessKey = Attribute identifiers are not checked. + +bad-has-attributes = + .accessKey = Attribute 'values' are checked. + +good-function-call = Last modified: { DATETIME($timeChanged, day: "numeric", month: "long", year: "numeric") } + +# $engineName (String) - The engine name that will currently be used for the private window. +good-variable-identifier = { $engineName } is your default search engine in Private Windows + +short-id = I am too short + +identifiers-in-selectors-should-be-ignored = + .label = { $tabCount -> + [1] Send Tab to Device + [UPPERCASE] Send Tab to Device + *[other] Send { $tabCount } Tabs to Device + } + +this-message-reference-is-ignored = + .label = { menu-quit.label } + +ok-message-with-html-and-var = This is a <a href="{ $url }">link</a> diff --git a/tools/lint/test/files/fluent-lint/brand-names-excluded.ftl b/tools/lint/test/files/fluent-lint/brand-names-excluded.ftl new file mode 100644 index 0000000000..9f3afa28b8 --- /dev/null +++ b/tools/lint/test/files/fluent-lint/brand-names-excluded.ftl @@ -0,0 +1,2 @@ +# Comment +bad-firefox1 = Welcome to Firefox diff --git a/tools/lint/test/files/fluent-lint/brand-names.ftl b/tools/lint/test/files/fluent-lint/brand-names.ftl new file mode 100644 index 0000000000..c338d920ca --- /dev/null +++ b/tools/lint/test/files/fluent-lint/brand-names.ftl @@ -0,0 +1,30 @@ +bad-firefox1 = Welcome to Firefox + +# Comment should be ignored when displaying the offset of the error +bad-firefox2 = Welcome to Firefox again +bad-firefox2b = <span>Welcome to Firefox<span> again +bad-firefox3 = <b>Firefox</b> +bad-firefox-excluded = <b>Firefox</b> + +bad-mozilla1 = Welcome to Mozilla +bad-mozilla2 = Welcome to Mozilla again +bad-mozilla2b = <span>Welcome to Mozilla</span> again +bad-mozilla3 = <b>Mozilla</b> + +bad-thunderbird1 = Welcome to Thunderbird +bad-thunderbird2 = <span>Welcome to Thunderbird</span> again +bad-thunderbird3 = <b>Thunderbird</b> + +good-firefox1 = Welcome to { -brand-firefox } +good-firefox2 = Welcome to { firefox-message } + +good-mozilla1 = Welcome to { -brand-mozilla } +good-mozilla2 = Welcome to { mozilla-message } + +good-thunderbird1 = Welcome to { -brand-thunderbird } +good-thunderbird2 = Welcome to { thunderbird-message } + +# There are no brand checks on terms +-brand-firefox = Firefox + +bland-message = No brands here. diff --git a/tools/lint/test/files/fluent-lint/comment-group1.ftl b/tools/lint/test/files/fluent-lint/comment-group1.ftl new file mode 100644 index 0000000000..32c19dc441 --- /dev/null +++ b/tools/lint/test/files/fluent-lint/comment-group1.ftl @@ -0,0 +1,35 @@ +# 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/. + +### Test group comments. + +fake-identifier-1 = Fake text + +## Pass: This group comment has proper spacing. + +fake-identifier-2 = Fake text +## Fail: (GC03) Group comments should have an empty line before them. + +fake-identifier-3 = Fake text + +## Fail: (GC02) Group comments should have an empty line after them. +fake-identifier-4 = Fake text + +## Pass: A single comment is fine. + +## Fail: (GC04) A group comment must be followed by at least one message. + +fake-identifier-5 = Fake text + + +## Fail: (GC03) Only allow 1 line above. + +fake-identifier-6 = Fake text + +## Fail: (GC02) Only allow 1 line below. + + +fake-identifier-6 = Fake text + +## Fail: (GC01) Group comments should not be at the end of a file. diff --git a/tools/lint/test/files/fluent-lint/comment-group2.ftl b/tools/lint/test/files/fluent-lint/comment-group2.ftl new file mode 100644 index 0000000000..47d29fa211 --- /dev/null +++ b/tools/lint/test/files/fluent-lint/comment-group2.ftl @@ -0,0 +1,15 @@ +# 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/. + +### Test group comments. + +## Pass: This group comment is followed by a term + +-fake-term = Fake text + +## Pass: The last group comment is allowed to be an empty ## + +fake-identifier-1 = Fake text + +## diff --git a/tools/lint/test/files/fluent-lint/comment-resource1.ftl b/tools/lint/test/files/fluent-lint/comment-resource1.ftl new file mode 100644 index 0000000000..f5d5e53d59 --- /dev/null +++ b/tools/lint/test/files/fluent-lint/comment-resource1.ftl @@ -0,0 +1,11 @@ +# 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/. + +### Pass: This is a resource comment with proper spacing. + +fake-identifier-1 = Fake text + +### Fail: (RC01) There should not be more than one resource comment + +fake-identifier-2 = Fake text diff --git a/tools/lint/test/files/fluent-lint/comment-resource2.ftl b/tools/lint/test/files/fluent-lint/comment-resource2.ftl new file mode 100644 index 0000000000..44a77f4e73 --- /dev/null +++ b/tools/lint/test/files/fluent-lint/comment-resource2.ftl @@ -0,0 +1,6 @@ +# 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/. +### Fail: (RC03) There should be an empty line preceeding. + +fake-identifier-1 = Fake text diff --git a/tools/lint/test/files/fluent-lint/comment-resource3.ftl b/tools/lint/test/files/fluent-lint/comment-resource3.ftl new file mode 100644 index 0000000000..b261404380 --- /dev/null +++ b/tools/lint/test/files/fluent-lint/comment-resource3.ftl @@ -0,0 +1,6 @@ +# 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/. + +### Fail: (RC02) There should be an empty line following. +fake-identifier-1 = Fake text diff --git a/tools/lint/test/files/fluent-lint/comment-resource4.ftl b/tools/lint/test/files/fluent-lint/comment-resource4.ftl new file mode 100644 index 0000000000..c24e8887f8 --- /dev/null +++ b/tools/lint/test/files/fluent-lint/comment-resource4.ftl @@ -0,0 +1,8 @@ +# 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/. + + +### Fail: (RC03) There should be only one space above. + +fake-identifier-1 = Fake text diff --git a/tools/lint/test/files/fluent-lint/comment-resource5.ftl b/tools/lint/test/files/fluent-lint/comment-resource5.ftl new file mode 100644 index 0000000000..60d8e8c264 --- /dev/null +++ b/tools/lint/test/files/fluent-lint/comment-resource5.ftl @@ -0,0 +1,8 @@ +# 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/. + +### Fail: (RC02) There should be only one space below. + + +fake-identifier-1 = Fake text diff --git a/tools/lint/test/files/fluent-lint/comment-resource6.ftl b/tools/lint/test/files/fluent-lint/comment-resource6.ftl new file mode 100644 index 0000000000..a2ca9abfe7 --- /dev/null +++ b/tools/lint/test/files/fluent-lint/comment-resource6.ftl @@ -0,0 +1,4 @@ +### Pass: Check two conditions. +### 1. This is an edge case, but we shouldn't error if there is only a resource comment. +### 2. Make sure this linter does not error if there is no license header. The license is +### checked with `mach lint license`. diff --git a/tools/lint/test/files/fluent-lint/excluded.ftl b/tools/lint/test/files/fluent-lint/excluded.ftl new file mode 100644 index 0000000000..79fe509ad6 --- /dev/null +++ b/tools/lint/test/files/fluent-lint/excluded.ftl @@ -0,0 +1,6 @@ +# This file is used to test excluding paths from tests. +Blah-blah = Uppercase letters in identifiers are not permitted. +blah-blah = This is a legal identifier. +blah_blah = Underscores in identifiers are not permitted. + +bad-apostrophe-1 = The bee's knees diff --git a/tools/lint/test/files/fluent-lint/tools/lint/fluent-lint/exclusions.yml b/tools/lint/test/files/fluent-lint/tools/lint/fluent-lint/exclusions.yml new file mode 100644 index 0000000000..1aecf8cedd --- /dev/null +++ b/tools/lint/test/files/fluent-lint/tools/lint/fluent-lint/exclusions.yml @@ -0,0 +1,17 @@ +# 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/. +--- +ID01: + messages: + - Invalid_Id + files: + - excluded.ftl +ID02: + messages: [] + files: [] +CO01: + messages: + - bad-firefox-excluded + files: + - brand-names-excluded.ftl diff --git a/tools/lint/test/files/isort/.flake8 b/tools/lint/test/files/isort/.flake8 new file mode 100644 index 0000000000..1933432319 --- /dev/null +++ b/tools/lint/test/files/isort/.flake8 @@ -0,0 +1,4 @@ +[flake8] +max-line-length = 100 +exclude = + subdir/exclude, diff --git a/tools/lint/test/files/isort/bad.py b/tools/lint/test/files/isort/bad.py new file mode 100644 index 0000000000..1871917373 --- /dev/null +++ b/tools/lint/test/files/isort/bad.py @@ -0,0 +1,8 @@ +import prova +import collections + + +def foobar(): + c = collections.Counter() + prova.ciao(c) + diff --git a/tools/lint/test/files/isort/subdir/exclude/bad.py b/tools/lint/test/files/isort/subdir/exclude/bad.py new file mode 100644 index 0000000000..58f5363ff0 --- /dev/null +++ b/tools/lint/test/files/isort/subdir/exclude/bad.py @@ -0,0 +1,9 @@ +import collections + +import prova + + +def foobar(): + c = collections.Counter() + prova.ciao(c) + diff --git a/tools/lint/test/files/license/.eslintrc.js b/tools/lint/test/files/license/.eslintrc.js new file mode 100644 index 0000000000..0449fdfa33 --- /dev/null +++ b/tools/lint/test/files/license/.eslintrc.js @@ -0,0 +1,5 @@ + +// Dot file to verify that it works +// without license + +"use strict"; diff --git a/tools/lint/test/files/license/bad.c b/tools/lint/test/files/license/bad.c new file mode 100644 index 0000000000..76e8197013 --- /dev/null +++ b/tools/lint/test/files/license/bad.c @@ -0,0 +1 @@ +int main() { return 0; } diff --git a/tools/lint/test/files/license/bad.js b/tools/lint/test/files/license/bad.js new file mode 100644 index 0000000000..5de1a72f1f --- /dev/null +++ b/tools/lint/test/files/license/bad.js @@ -0,0 +1,6 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Pulic Unknown License as published by + * the Free Software Foundation, version 3. + * + */ diff --git a/tools/lint/test/files/license/good-other.h b/tools/lint/test/files/license/good-other.h new file mode 100644 index 0000000000..fb915e9b26 --- /dev/null +++ b/tools/lint/test/files/license/good-other.h @@ -0,0 +1,9 @@ +/* +Permission to use, copy, modify, distribute and sell this software +and its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and +that both that copyright notice and this permission notice appear +in supporting documentation. Samphan Raruenrom makes no +representations about the suitability of this software for any +purpose. It is provided "as is" without express or implied warranty. +*/ diff --git a/tools/lint/test/files/license/good.c b/tools/lint/test/files/license/good.c new file mode 100644 index 0000000000..d1a6827fb1 --- /dev/null +++ b/tools/lint/test/files/license/good.c @@ -0,0 +1,8 @@ + +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* 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/. */ + +int main() { return 0; } diff --git a/tools/lint/test/files/license/good.js b/tools/lint/test/files/license/good.js new file mode 100644 index 0000000000..d10ae3a8d5 --- /dev/null +++ b/tools/lint/test/files/license/good.js @@ -0,0 +1,7 @@ +#!/usr/bin/env node +/* 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/. */ + +# Nothing + diff --git a/tools/lint/test/files/lintpref/bad.js b/tools/lint/test/files/lintpref/bad.js new file mode 100644 index 0000000000..ab55ba5dad --- /dev/null +++ b/tools/lint/test/files/lintpref/bad.js @@ -0,0 +1,2 @@ +// Real test pref, matching value. +pref("dom.webidl.test1", true); diff --git a/tools/lint/test/files/lintpref/good.js b/tools/lint/test/files/lintpref/good.js new file mode 100644 index 0000000000..0bf81c8f58 --- /dev/null +++ b/tools/lint/test/files/lintpref/good.js @@ -0,0 +1,6 @@ +// Fake prefs. +pref("foo.bar", 1); +pref("foo.baz", "1.234"); + +// Real test pref, different value. +pref("dom.webidl.test1", false); diff --git a/tools/lint/test/files/pylint/bad.py b/tools/lint/test/files/pylint/bad.py new file mode 100644 index 0000000000..61b69a49cf --- /dev/null +++ b/tools/lint/test/files/pylint/bad.py @@ -0,0 +1,5 @@ +def foo(): + useless_var = 1 + useless_var = true + return "true" + print("unreachable")
\ No newline at end of file diff --git a/tools/lint/test/files/pylint/good.py b/tools/lint/test/files/pylint/good.py new file mode 100644 index 0000000000..c867dc66ec --- /dev/null +++ b/tools/lint/test/files/pylint/good.py @@ -0,0 +1,3 @@ +def foo(): + a = 1 + 1 + return a diff --git a/tools/lint/test/files/rst/.dotfile.rst b/tools/lint/test/files/rst/.dotfile.rst new file mode 100644 index 0000000000..be24e1d161 --- /dev/null +++ b/tools/lint/test/files/rst/.dotfile.rst @@ -0,0 +1,11 @@ +============ +Coding style +========== + +foo bar +~~~~~ + + +This file has error but should not be there +as we don't analyze dot files + diff --git a/tools/lint/test/files/rst/bad.rst b/tools/lint/test/files/rst/bad.rst new file mode 100644 index 0000000000..c9b60f613e --- /dev/null +++ b/tools/lint/test/files/rst/bad.rst @@ -0,0 +1,20 @@ +============ +Coding style +============ + + +This document attempts to explain the basic styles and patterns used in +the Mozilla codebase. New code should try to conform to these standards, +so it is as easy to maintain as existing code. There are exceptions, but +it's still important to know the rules! + + +Whitespace +~~~~~~~~ + +Line length +~~~~~~~~~~~ + +Line length +~~~~~~~~~~~ + diff --git a/tools/lint/test/files/rst/bad2.rst b/tools/lint/test/files/rst/bad2.rst new file mode 100644 index 0000000000..81c35dde06 --- /dev/null +++ b/tools/lint/test/files/rst/bad2.rst @@ -0,0 +1,4 @@ +==== +Test +=== + diff --git a/tools/lint/test/files/rst/bad3.rst b/tools/lint/test/files/rst/bad3.rst new file mode 100644 index 0000000000..b7e66e5c92 --- /dev/null +++ b/tools/lint/test/files/rst/bad3.rst @@ -0,0 +1,6 @@ + +.. _When_Should_I_Use_a_Hashtable.3F: + +When Should I Use a Hashtable? +------------------------------ + diff --git a/tools/lint/test/files/rst/good.rst b/tools/lint/test/files/rst/good.rst new file mode 100644 index 0000000000..fd12da85d3 --- /dev/null +++ b/tools/lint/test/files/rst/good.rst @@ -0,0 +1,11 @@ +============ +Coding style +============ + + +This document attempts to explain the basic styles and patterns used in +the Mozilla codebase. New code should try to conform to these standards, +so it is as easy to maintain as existing code. There are exceptions, but +it's still important to know the rules! + + diff --git a/tools/lint/test/files/rustfmt/subdir/bad.rs b/tools/lint/test/files/rustfmt/subdir/bad.rs new file mode 100644 index 0000000000..fb1746fafd --- /dev/null +++ b/tools/lint/test/files/rustfmt/subdir/bad.rs @@ -0,0 +1,16 @@ +fn main() { + // Statements here are executed when the compiled binary is called + + // Print text to the console + println!("Hello World!"); + // Clippy detects this as a swap and considers this as an error + let mut a = + 1; + let mut b=1; + + a = + b; + b = a; + + +} diff --git a/tools/lint/test/files/rustfmt/subdir/bad2.rs b/tools/lint/test/files/rustfmt/subdir/bad2.rs new file mode 100644 index 0000000000..a4236a2de7 --- /dev/null +++ b/tools/lint/test/files/rustfmt/subdir/bad2.rs @@ -0,0 +1,17 @@ +fn main() { + // Statements here are executed when the compiled binary is called + + // Print text to the console + println!("Hello World!"); + let mut a; + let mut b=1; + let mut vec = Vec::new(); + vec.push(1); + vec.push(2); + + + for x in 5..10 - 5 { + a = x; + } + + } diff --git a/tools/lint/test/files/rustfmt/subdir/good.rs b/tools/lint/test/files/rustfmt/subdir/good.rs new file mode 100644 index 0000000000..9bcaee67b7 --- /dev/null +++ b/tools/lint/test/files/rustfmt/subdir/good.rs @@ -0,0 +1,6 @@ +fn main() { + // Statements here are executed when the compiled binary is called + + // Print text to the console + println!("Hello World!"); +} diff --git a/tools/lint/test/files/shellcheck/bad.sh b/tools/lint/test/files/shellcheck/bad.sh new file mode 100644 index 0000000000..b2eb195558 --- /dev/null +++ b/tools/lint/test/files/shellcheck/bad.sh @@ -0,0 +1,3 @@ +#!/bin/sh +hello="Hello world" +echo $1 diff --git a/tools/lint/test/files/shellcheck/good.sh b/tools/lint/test/files/shellcheck/good.sh new file mode 100644 index 0000000000..e61d501955 --- /dev/null +++ b/tools/lint/test/files/shellcheck/good.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo "Hello world" diff --git a/tools/lint/test/files/trojan-source/README b/tools/lint/test/files/trojan-source/README new file mode 100644 index 0000000000..343a9d0c3c --- /dev/null +++ b/tools/lint/test/files/trojan-source/README @@ -0,0 +1,5 @@ +These examples are taken from trojan source: +https://github.com/nickboucher/trojan-source + +The examples are published under the MIT license. + diff --git a/tools/lint/test/files/trojan-source/commenting-out.cpp b/tools/lint/test/files/trojan-source/commenting-out.cpp new file mode 100644 index 0000000000..d67df70ce1 --- /dev/null +++ b/tools/lint/test/files/trojan-source/commenting-out.cpp @@ -0,0 +1,9 @@ +#include <iostream> + +int main() { + bool isAdmin = false; + /* } if (isAdmin) begin admins only */ + std::cout << "You are an admin.\n"; + /* end admins only { */ + return 0; +}
\ No newline at end of file diff --git a/tools/lint/test/files/trojan-source/early-return.py b/tools/lint/test/files/trojan-source/early-return.py new file mode 100644 index 0000000000..2797d8ae9f --- /dev/null +++ b/tools/lint/test/files/trojan-source/early-return.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 +bank = { 'alice': 100 } + +def subtract_funds(account: str, amount: int): + ''' Subtract funds from bank account then ''' ;return + bank[account] -= amount + return + +subtract_funds('alice', 50)
\ No newline at end of file diff --git a/tools/lint/test/files/trojan-source/invisible-function.rs b/tools/lint/test/files/trojan-source/invisible-function.rs new file mode 100644 index 0000000000..b32efb0372 --- /dev/null +++ b/tools/lint/test/files/trojan-source/invisible-function.rs @@ -0,0 +1,15 @@ +fn isAdmin() { + return false; +} + +fn isAdmin() { + return true; +} + +fn main() { + if isAdmin() { + printf("You are an admin\n"); + } else { + printf("You are NOT an admin.\n"); + } +}
\ No newline at end of file diff --git a/tools/lint/test/files/updatebot/.yamllint b/tools/lint/test/files/updatebot/.yamllint new file mode 100644 index 0000000000..4f11bbd6c5 --- /dev/null +++ b/tools/lint/test/files/updatebot/.yamllint @@ -0,0 +1,6 @@ +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +# Explicity default .yamllint to isolate tests from tree-wide yamlint config. +--- +extends: default diff --git a/tools/lint/test/files/updatebot/cargo-mismatch.yaml b/tools/lint/test/files/updatebot/cargo-mismatch.yaml new file mode 100644 index 0000000000..ac18d2b87c --- /dev/null +++ b/tools/lint/test/files/updatebot/cargo-mismatch.yaml @@ -0,0 +1,44 @@ +--- +# Version of this schema +schema: 1 + +bugzilla: + # Bugzilla product and component for this directory and subdirectories + product: Core + component: "Graphics: WebGPU" + +# Document the source of externally hosted code +origin: + + # Short name of the package/library + name: wgpu + + description: A cross-platform pure-Rust graphics API + + # Full URL for the package's homepage/etc + # Usually different from repository url + url: https://github.com/gfx-rs/wgpu + + # Human-readable identifier for this version/release + # Generally "version NNN", "tag SSS", "bookmark SSS" + release: commit 32af4f56 + + # Revision to pull in + # Must be a long or short commit SHA (long preferred) + revision: idontmatchanything + + license: ['MIT', 'Apache-2.0'] + +updatebot: + maintainer-phab: jimb + maintainer-bz: jimb@mozilla.com + tasks: + - type: vendoring + enabled: true + frequency: 1 week + +vendoring: + url: https://github.com/gfx-rs/wgpu + source-hosting: github + vendor-directory: gfx/wgpu_bindings/ + flavor: rust diff --git a/tools/lint/test/files/updatebot/good1.yaml b/tools/lint/test/files/updatebot/good1.yaml new file mode 100644 index 0000000000..f57d2c5b4c --- /dev/null +++ b/tools/lint/test/files/updatebot/good1.yaml @@ -0,0 +1,44 @@ +--- +schema: 1 + +bugzilla: + product: Core + component: Graphics + +origin: + name: angle + + description: ANGLE - Almost Native Graphics Layer Engine + + url: https://chromium.googlesource.com/angle/angle + + # Note that while the vendoring information here, including revision, + # release, and upstream repo locations refer to the third party upstream, + # Angle is vendored from a mozilla git repository that pulls from + # upstream and mainntains local patches there. + release: commit 018f85dea11fd5e41725750c6958695a6b8e8409 + revision: 018f85dea11fd5e41725750c6958695a6b8e8409 + + license: BSD-3-Clause + +updatebot: + maintainer-phab: jgilbert + maintainer-bz: jgilbert@mozilla.com + tasks: + - type: commit-alert + enabled: true + branch: chromium/4515 + needinfo: ["jgilbert@mozilla.com"] + +vendoring: + url: https://chromium.googlesource.com/angle/angle + tracking: tag + source-hosting: angle + vendor-directory: gfx/angle/checkout + skip-vendoring-steps: ["fetch", "update-moz-build"] + + update-actions: + - action: run-script + script: '{yaml_dir}/auto-update-angle.sh' + args: ['{revision}'] + cwd: '{cwd}' diff --git a/tools/lint/test/files/updatebot/good2.yaml b/tools/lint/test/files/updatebot/good2.yaml new file mode 100644 index 0000000000..0161d28b11 --- /dev/null +++ b/tools/lint/test/files/updatebot/good2.yaml @@ -0,0 +1,74 @@ +--- +# Version of this schema +schema: 1 + +bugzilla: + # Bugzilla product and component for this directory and subdirectories + product: Core + component: "Audio/Video: Playback" + +# Document the source of externally hosted code +origin: + + # Short name of the package/library + name: dav1d + + description: dav1d, a fast AV1 decoder + + # Full URL for the package's homepage/etc + # Usually different from repository url + url: https://code.videolan.org/videolan/dav1d + + # Human-readable identifier for this version/release + # Generally "version NNN", "tag SSS", "bookmark SSS" + release: ffb59680356fd210816cf9e46d9d023ade1f4d5a + + # Revision to pull in + # Must be a long or short commit SHA (long preferred) + revision: ffb59680356fd210816cf9e46d9d023ade1f4d5a + + # The package's license, where possible using the mnemonic from + # https://spdx.org/licenses/ + # Multiple licenses can be specified (as a YAML list) + # A "LICENSE" file must exist containing the full license text + license: BSD-2-Clause + + license-file: COPYING + +updatebot: + maintainer-phab: chunmin + maintainer-bz: cchang@mozilla.com + tasks: + - type: vendoring + enabled: true + frequency: release + +vendoring: + url: https://code.videolan.org/videolan/dav1d + source-hosting: gitlab + vendor-directory: third_party/dav1d + + exclude: + - build/.gitattributes + - build/.gitignore + - doc + - examples + - package + - tools + + generated: + - '{yaml_dir}/vcs_version.h' + - '{yaml_dir}/version.h' + + update-actions: + - action: copy-file + from: include/vcs_version.h.in + to: '{yaml_dir}/vcs_version.h' + - action: replace-in-file + pattern: '@VCS_TAG@' + with: '{revision}' + file: '{yaml_dir}/vcs_version.h' + - action: run-script + script: '{yaml_dir}/update-version.sh' + cwd: '{vendor_dir}' + args: ['{yaml_dir}/version.h'] diff --git a/tools/lint/test/files/updatebot/no-revision.yaml b/tools/lint/test/files/updatebot/no-revision.yaml new file mode 100644 index 0000000000..4d581508d8 --- /dev/null +++ b/tools/lint/test/files/updatebot/no-revision.yaml @@ -0,0 +1,43 @@ +--- +schema: 1 + +bugzilla: + product: Core + component: Graphics + +origin: + name: angle + + description: ANGLE - Almost Native Graphics Layer Engine + + url: https://chromium.googlesource.com/angle/angle + + # Note that while the vendoring information here, including revision, + # release, and upstream repo locations refer to the third party upstream, + # Angle is vendored from a mozilla git repository that pulls from + # upstream and mainntains local patches there. + release: commit 018f85dea11fd5e41725750c6958695a6b8e8409 + + license: BSD-3-Clause + +updatebot: + maintainer-phab: jgilbert + maintainer-bz: jgilbert@mozilla.com + tasks: + - type: commit-alert + enabled: true + branch: chromium/4515 + needinfo: ["jgilbert@mozilla.com"] + +vendoring: + url: https://chromium.googlesource.com/angle/angle + tracking: tag + source-hosting: angle + vendor-directory: gfx/angle/checkout + skip-vendoring-steps: ["fetch", "update-moz-build"] + + update-actions: + - action: run-script + script: '{yaml_dir}/auto-update-angle.sh' + args: ['{revision}'] + cwd: '{cwd}' diff --git a/tools/lint/test/files/yaml/.yamllint b/tools/lint/test/files/yaml/.yamllint new file mode 100644 index 0000000000..4f11bbd6c5 --- /dev/null +++ b/tools/lint/test/files/yaml/.yamllint @@ -0,0 +1,6 @@ +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +# Explicity default .yamllint to isolate tests from tree-wide yamlint config. +--- +extends: default diff --git a/tools/lint/test/files/yaml/bad.yml b/tools/lint/test/files/yaml/bad.yml new file mode 100644 index 0000000000..195ac7b030 --- /dev/null +++ b/tools/lint/test/files/yaml/bad.yml @@ -0,0 +1,8 @@ +--- +yamllint: + description: YAML linteraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaax + include: + - .cron.yml + - browser/config/ + - wrong + application:bar diff --git a/tools/lint/test/files/yaml/good.yml b/tools/lint/test/files/yaml/good.yml new file mode 100644 index 0000000000..b30941b797 --- /dev/null +++ b/tools/lint/test/files/yaml/good.yml @@ -0,0 +1,6 @@ +--- +yamllint: + description: YAML linter + include: + - .cron.yml + - browser/config/ |