Skip to content

Commit

Permalink
Switch our usage of regex-lint to preamble (#17724)
Browse files Browse the repository at this point in the history
This change has been a long time coming 😸 

We're now using `premable` for copyright headers, auto-added in `fmt` instead of simply checking in `lint`.
Annnd now we're formatting the rust files as well (look at all those missing headers)

We can discuss offline what happens to `regex-lint` 😄
  • Loading branch information
thejcannon committed Dec 6, 2022
1 parent 1d4a06e commit bca1b5a
Show file tree
Hide file tree
Showing 60 changed files with 123 additions and 34 deletions.
6 changes: 6 additions & 0 deletions build-support/preambles/config.yaml
@@ -0,0 +1,6 @@
"**/*.py:!**/__init__.py:**/BUILD:**/BUILD.*": |+
# Copyright $year Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
"**/*.rs": |+
// Copyright $year Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
32 changes: 0 additions & 32 deletions build-support/regexes/config.yaml

This file was deleted.

5 changes: 3 additions & 2 deletions pants.toml
Expand Up @@ -30,6 +30,7 @@ backend_packages.add = [
"pants.backend.experimental.scala.lint.scalafmt",
"pants.backend.experimental.scala.debug_goals",
"pants.backend.experimental.visibility",
"pants.backend.tools.preamble",
"pants.explorer.server",
"internal_plugins.releases",
"internal_plugins.test_lockfile_fixtures",
Expand Down Expand Up @@ -199,8 +200,8 @@ lockfile = "3rdparty/python/mypy.lock"
[coverage-py]
interpreter_constraints = [">=3.7,<3.10"]

[regex-lint]
config = "@build-support/regexes/config.yaml"
[preamble]
template_by_globs = "@build-support/preambles/config.yaml"

[generate-lockfiles]
custom_command = "build-support/bin/generate_all_lockfiles.sh"
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/async_latch/src/tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::time::Duration;

use tokio::time::sleep;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/async_value/src/tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use crate::AsyncValue;

use std::time::Duration;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/concrete_time/src/tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use crate::{Duration, TimeSpan};

#[test]
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/fs/brfs/src/syscall_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
// TODO: Write a bunch more syscall-y tests to test that each syscall for each file/directory type
// acts as we expect.

Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/fs/brfs/src/tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use tempfile;
use testutil;

Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/fs/src/posixfs_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::path::{Path, PathBuf};
use std::sync::Arc;

Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/fs/src/tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use crate::RelativePath;

#[test]
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/fs/store/src/immutable_inputs.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::{BTreeMap, BTreeSet, HashMap};
use std::path::{Path, PathBuf};
use std::sync::Arc;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/fs/store/src/local.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use super::{EntryType, ShrinkBehavior};

use std::collections::{BinaryHeap, HashSet};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/fs/store/src/local_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use crate::local::ByteStore;
use crate::{EntryType, LocalOptions, ShrinkBehavior};

Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/fs/store/src/remote.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::cmp::min;
use std::collections::{BTreeMap, HashSet};
use std::convert::TryInto;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/fs/store/src/remote_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::{BTreeMap, HashSet};
use std::time::Duration;

Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/fs/store/src/snapshot_ops_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::fs::create_dir_all;
use std::path::Path;
use std::sync::Arc;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/fs/store/src/snapshot_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::convert::TryInto;
use std::path::{Path, PathBuf};
use std::sync::Arc;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/fs/store/src/tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::fs::File;
use std::io::Read;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/graph/src/entry.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::mem;
use std::sync::Arc;

Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/graph/src/tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::cmp;
use std::collections::{HashMap, HashSet};
use std::future::Future;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/grpc_util/src/hyper.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::ops::Deref;
use std::pin::Pin;
use std::task::{Context, Poll};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/grpc_util/src/tls.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::sync::Arc;

use rustls::{ClientConfig, RootCertStore, ServerCertVerified, ServerCertVerifier, TLSError};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/hashing/src/digest_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use self::serde_test::{assert_tokens, Token};
use super::Digest;
use super::Fingerprint;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/hashing/src/fingerprint_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use crate::Fingerprint;
use serde_test::{assert_ser_tokens, Token};

Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/hashing/src/hasher_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
#[test]
fn hashes() {
let mut src = "meep".as_bytes();
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/nailgun/src/tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use crate::Server;

use std::path::PathBuf;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/bounded.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::borrow::Cow;
use std::cmp::{max, min, Ordering, Reverse};
use std::collections::VecDeque;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/bounded_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::sync::Arc;
use std::time::{Duration, Instant};

Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/cache.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::fmt::{self, Debug};
use std::sync::Arc;
use std::time::Instant;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/cache_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::convert::TryInto;
use std::io::Write;
use std::path::PathBuf;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/children.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::ops::{Deref, DerefMut};
use std::sync::atomic::{AtomicBool, Ordering};
use std::{thread, time};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/docker.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::BTreeMap;
use std::fmt;
use std::path::{Path, PathBuf};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/docker_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::{BTreeMap, BTreeSet, HashSet};
use std::env;
use std::path::PathBuf;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/local.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::{BTreeMap, BTreeSet, HashSet};
use std::ffi::OsStr;
use std::fmt::{self, Debug};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/local_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::{BTreeMap, BTreeSet, HashSet};
use std::path::PathBuf;
use std::str;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/nailgun/mod.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::{BTreeMap, BTreeSet};
use std::fmt::{self, Debug};
use std::net::SocketAddr;
Expand Down
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use itertools::Itertools;
use std::slice::Iter;

Expand Down
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use crate::nailgun::parsed_jvm_command_lines::ParsedJVMCommandLines;

// TODO we should be able to use https://docs.rs/crate/derive_builder/0.8.0
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/nailgun/tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::path::PathBuf;

use store::{ImmutableInputs, Store};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/named_caches.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};

Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/remote.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::cmp::Ordering;
use std::collections::{BTreeMap, HashMap};
use std::convert::TryInto;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/remote_cache.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::{BTreeMap, HashSet};
use std::convert::TryInto;
use std::fmt::{self, Debug};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/remote_cache_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::{BTreeMap, HashSet};
use std::convert::TryInto;
use std::sync::atomic::{AtomicUsize, Ordering};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/remote_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::{BTreeMap, BTreeSet, HashSet};
use std::convert::TryInto;
use std::path::{Path, PathBuf};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/protos/src/conversions.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
impl<'a> From<&'a hashing::Digest> for crate::gen::build::bazel::remote::execution::v2::Digest {
fn from(d: &'a hashing::Digest) -> Self {
Self {
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/protos/src/conversions_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::convert::TryInto;

use hashing;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/protos/src/verification.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::HashSet;

use hashing::Digest;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/protos/src/verification_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use hashing::EMPTY_DIGEST;

use crate::gen::build::bazel::remote::execution::v2::{Digest, Directory, DirectoryNode, FileNode};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/rule_graph/src/tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::fmt;

use indexmap::{indexset, IndexSet};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/sharded_lmdb/src/tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::HashMap;

use bytes::{Buf, Bytes};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/src/externs/interface_tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use crate::externs::interface::generate_panic_string;

use std::any::Any;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/stdio/src/term.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::fs::File;
use std::io::{Read, Write};
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/testutil/mock/src/cas.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::HashMap;
use std::net::SocketAddr;
use std::sync::atomic::AtomicBool;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/testutil/mock/src/cas_service.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::HashMap;
use std::convert::TryInto;
use std::pin::Pin;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/testutil/mock/src/execution_server.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::any::type_name;
use std::collections::VecDeque;
use std::fmt::Debug;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/testutil/src/data.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use grpc_util::prost::MessageExt;
use protos::gen::build::bazel::remote::execution::v2 as remexec;

Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/testutil/src/file.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::io::Read;
use std::os::unix::fs::PermissionsExt;
use std::path::Path;
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/testutil/src/path.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::env;
use std::path::PathBuf;

Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/watch/src/tests.rs
@@ -1,3 +1,5 @@
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use crate::{Invalidatable, InvalidationWatcher};

use std::collections::HashSet;
Expand Down

0 comments on commit bca1b5a

Please sign in to comment.