Convert tidy to a non-egg Python package

It seems that servo-tidy is only used by webrender in my GitHub
searches. WebRender could simply use `rustfmt` and the tidy on pypi
hasn't been updated since 2018. Converting tidy to a normal Python
package removes the maintenance burden of continually fixing the easy
install configuration.

Fixes #29094.
Fixes #29334.
This commit is contained in:
Martin Robinson 2023-06-15 12:34:27 +02:00
parent fa266abd29
commit 81433a8684
No known key found for this signature in database
GPG key ID: D56AA4FA55EFE6F8
54 changed files with 68 additions and 266 deletions

View file

@ -0,0 +1,11 @@
[package]
name = "test"
version = "0.0.1"
authors = ["The Servo Project Developers"]
publish = false
[dependencies]
test-package = { version = "*" }
[lib]
path = "lib.rs"

View file

@ -0,0 +1,8 @@
# 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.

View file

@ -0,0 +1,5 @@
// 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.

View file

@ -0,0 +1,19 @@
/* 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 https://mozilla.org/MPL/2.0/. */
#![feature(plugin)]
#![plugin(script_plugins)]
extern crate script;
use script::test::Dom;
use script::test::DomRefCell;
use script::test::Node;
struct Foo {
bar: DomRefCell<Dom<Node>>
//~^ ERROR Banned type DomRefCell<Dom<T>> detected. Use MutDom<T> instead
}
fn main() {}

21
python/tidy/tests/ban.rs Normal file
View file

@ -0,0 +1,21 @@
/* 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 https://mozilla.org/MPL/2.0/. */
#![feature(plugin)]
#![plugin(script_plugins)]
extern crate js;
use js::jsval::JSVal;
use std::cell::Cell;
use std::cell::UnsafeCell;
struct Foo {
bar: Cell<JSVal>,
//~^ ERROR Banned type Cell<JSVal> detected. Use MutDom<JSVal> instead
foo: UnsafeCell<JSVal>
//~^ NOT AN ERROR
}
fn main() {}

View file

@ -0,0 +1,26 @@
[root]
name = "servo"
version = "0.0.1"
[[package]]
name = "test_blocked"
version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "test_exception"
version = "0.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "test_unneeded_exception"
version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
]

View file

@ -0,0 +1,7 @@
{
"key": "value",
"other_key": {
"the_duplicated_key": 1,
"the_duplicated_key": 2
}
}

View file

@ -0,0 +1,7 @@
---
duplicate_yaml_key:
- value1
other_key:
- value2
duplicate_yaml_key:
- value3

View file

@ -0,0 +1,50 @@
[root]
name = "servo"
version = "0.0.1"
[[package]]
name = "test"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "test"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "test2"
version = "0.1.0"
source = "git+https://github.com/user/test2#c54edsf"
dependencies = [
"test 0.4.9",
]
[[package]]
name = "test3"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"test 0.5.1",
]
[[package]]
name = "test3"
version = "0.5.1"
source = "git+https://github.com/user/test3#c54edsf"
[[package]]
name = "test4"
version = "0.1.0"
source = "git+https://github.com/user/test4#c54edsf"
dependencies = [
"test3 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "test5"
version = "0.1.0"
source = "git+https://github.com/"
dependencies = [
"test3 0.5.1 (git+https://github.com/user/test3)",
]

View file

View file

@ -0,0 +1 @@
/* Incorrect license here */

14
python/tidy/tests/lib.rs Normal file
View file

@ -0,0 +1,14 @@
/* 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 https://mozilla.org/MPL/2.0/. */
#![feature(def)]
#![feature(abc)]
#![feature(abc, def, ghi)]
#![feature(aaa)]
#![feature(def, ghi, abc)]
#![feature(ghi)]
#![feature(abd, hef)]

View file

@ -0,0 +1,5 @@
from servo_tidy.tidy import LintRunner
class Lint(LintRunner):
def run(self):
yield None

View file

@ -0,0 +1,5 @@
from servo_tidy.tidy import LintRunner
class Linter(LintRunner):
def run(self):
pass

View file

@ -0,0 +1,5 @@
from servo_tidy.tidy import LintRunner
class Lint(LintRunner):
def some_method(self):
pass

View file

@ -0,0 +1,2 @@
class Lint(object):
pass

View file

View file

@ -0,0 +1,6 @@
from servo_tidy.tidy import LintRunner
class Lint(LintRunner):
def run(self):
for _ in [None]:
yield ('path', 0, 'foobar')

View file

@ -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 https://mozilla.org/MPL/2.0/. */
println!("really really loooooooooooooooooooooooooooooooooooooooooooong lineeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee");
let url = "http://www.should.skip/really-looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong-url-strings";

View file

@ -0,0 +1,4 @@
{
"key": "value",
"other_key": "value_with_bad_quote'
}

View file

@ -0,0 +1,5 @@
skip: true
[html]
skip: false
[never_going_to_exist]
skip: false

View file

@ -0,0 +1,5 @@
# vim: set noexpandtab:
// vi: et:
/* ex: et:
anything -*-Lisp-*-
-*- mode: Lisp -*-

View file

@ -0,0 +1,28 @@
/* 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 https://mozilla.org/MPL/2.0/. */
// This puts a "multi-line string
// inside of a comment" and then subsequently has a hyphenated-phrase
const FOO: &'static str = "Do not confuse 'apostrophes',
They can be 'lifetimes' or 'characters'";
fn main() {
assert!(foo("test
foo-bar"));
assert!(foo("test
test2 \"
foo-bar"));
assert!(foo("test
test2 \
foo-bar"));
println!("This is a multiline string with a URL, which kinda, \
sorta looks like a comment https://github.com/servo/servo/");
}

View file

@ -0,0 +1,2 @@
---
non-list-key: "string string"

View file

@ -0,0 +1,7 @@
---
# This is a buildbot_steps.yml file that should break linting becasue it is not a
# mapping to a list of strings
mapping_key:
- - list_of_list
- sublist_item1
- sublist_item2

View file

@ -0,0 +1,85 @@
/* 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 https://mozilla.org/MPL/2.0/. */
use app_units::Au;
use raqote::{GradientStop, Source, SolidSource};
use raqote::{Source, SolidSource},
ColorPattern, CompositionOp};
use euclid::Size2D;
use raqote::Gradient;
use raqote::{Gradient};
mod paint_context;
pub mod display_list;
mod test::{
};
extern crate webrender_api;
extern crate style_traits;
#[foo = "bar,baz"]
#[derive(Copy,Debug, ComputeSquaredDistance)]
impl test {
fn test_fun(y:f32)->f32{
let x=5;
x = x-1;
x = x*x;
let z = match y {
1 =>2,
2 => 1,
};
let z = &Vec<T>;
struct Member {
member_name:"Foo"
member_id:5
}
}
fn test_fun2(y : &String, z : &Vec<f32>, r: &Root<isize>, s: &DomRoot<isize>) -> () {
let x = true;
x
&& x;
if x {
;
}
else {
;
}
}
type Text_Fun3 = fn( i32) -> i32;
fn test_fun3<Text_Fun3>( y: Text_Fun3) {
let (x, y) = (1, 2) // Should not trigger
test_fun( x);
test_fun (y);
}
// Should not be triggered
macro_rules! test_macro ( ( $( $fun:ident = $flag:ident ; )* ) => ());
let var
= "val";
fn test_fun4()
{
}
let var = if true {
"true"
} else { // Should not trigger
"false"
} // Should not trigger
if true { // Double space after keyword
42
} else {
let xif = 42 in { xif } // Should not trigger
}
let option = Some(3);
println!("{}", option.unwrap());
panic!("What a way to end.");
}

View file

@ -0,0 +1,19 @@
key-outside = ""
[configs]
skip-check-length = false
skip-check-licenses = false
wrong-key = false
[blocked-packages]
[wrong]
wrong-key = true
[ignore]
files = [
"./fake/file.html",
]
directories = [
"./fake/dir",
]

View file

@ -0,0 +1,4 @@
#!/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 https://mozilla.org/MPL/2.0/.

View file

@ -0,0 +1,14 @@
#!/bin/bash
#
# Tests tidy for shell scripts.
set -o nounset
# Talking about some `concept in backticks` # shouldn't trigger
echo "hello world"
some_var=`echo "command substitution"`
another_var="$some_var"
if [ -z "${some_var}" ]; then
echo "should have used [["
fi
[ -z "${another_var}" ]

View file

@ -0,0 +1,10 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 https://mozilla.org/MPL/2.0/. */
interface Test {
[SameObject ]
readonly attribute Node root;
};

View file

@ -0,0 +1,32 @@
/* 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 https://mozilla.org/MPL/2.0/. */
impl SpecLinkMethods for SpecLink {
amacro!("Macros inside impls should trigger spec checks.")
// Method declarations should trigger spec checks.
fn Test(&self) -> f32 {
amacro!("Macros inside function declarations should not trigger spec checks.");
if unsafe { false } {
}
amacro!("Even if there's weird brace counts.");
0
}
// A spec link.
// https://example.com/
fn Foo() {}
/// A spec link.
/// <https://example.com/>
fn Foo() {}
/// A spec link.
/// <https://example.com/>
/// Doc comments are OK
// Regular comments are OK
#[allow(attributes_too)]
fn Foo() {}
}

View file

@ -0,0 +1,7 @@
{
"key": "value",
"other_key": {
"b": 1,
"a": 2
}
}

View file

@ -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 https://mozilla.org/MPL/2.0/. */
// https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-putimagedata
// https://html.spec.whatwg.org/#typographic-conventions

View file

@ -0,0 +1,7 @@
/* 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 https://mozilla.org/MPL/2.0/. */
pub struct TestStruct(
pub testMember1: usize,
pub testMember2: bool, );