--all-targets does not run targets that needs some features which are not provided. --all-features is NOT possible as we have some features which are conflicting.

The only possibility is to manually add the features we need to check in CI to the clippy query
This commit is contained in:
Marcel Märtens 2021-05-21 14:34:34 +02:00
parent f2eedf81f4
commit 846df3a18a
6 changed files with 63 additions and 92 deletions

View File

@ -6,7 +6,7 @@ code-quality:
script:
- ln -s /dockercache/target target
- rm -r target/debug/incremental/* || echo "all good" # TMP FIX FOR 2021-03-22-nightly
- cargo clippy --all-targets --locked -- -D warnings
- cargo clippy --all-targets --locked --features="bin_csv,bin_bot" -- -D warnings
- cargo fmt --all -- --check
security:

View File

@ -45,15 +45,14 @@ fn main() {
let runtime = Arc::new(Runtime::new().unwrap());
let runtime2 = Arc::clone(&runtime);
let addr = ConnectionArgs::Tcp {
prefer_ipv6: false,
hostname: server_addr,
};
// Create a client.
let mut client = runtime
.block_on(async {
let addr = ConnectionArgs::resolve(&server_addr, false)
.await
.expect("dns resolve failed");
Client::new(addr, None, runtime2, &mut None).await
})
.block_on(Client::new(addr, runtime2, &mut None))
.expect("Failed to create client instance");
println!("Server info: {:?}", client.server_info());

View File

@ -1,5 +1,3 @@
#![feature(str_split_once)]
#[macro_use] extern crate serde;
use authc::AuthClient;
@ -54,15 +52,13 @@ pub struct BotClient {
pub fn make_client(runtime: &Arc<Runtime>, server: &str) -> Client {
let runtime2 = Arc::clone(&runtime);
let view_distance: Option<u32> = None;
runtime.block_on(async {
let connection_args = ConnectionArgs::resolve(server, false)
.await
.expect("DNS resolution failed");
Client::new(connection_args, view_distance, runtime2, &mut None)
.await
.expect("Failed to connect to server")
})
let addr = ConnectionArgs::Tcp {
prefer_ipv6: false,
hostname: server.to_owned(),
};
runtime
.block_on(Client::new(addr, runtime2, &mut None))
.expect("Failed to connect to server")
}
impl BotClient {
@ -84,7 +80,7 @@ impl BotClient {
for (username, client) in self.bot_clients.iter_mut() {
//trace!("cl {:?}: {:?}", username, client.character_list());
trace!(?username, "tick");
let msgs: Result<Vec<veloren_client::Event>, veloren_client::Error> =
let _msgs: Result<Vec<veloren_client::Event>, veloren_client::Error> =
client.tick(comp::ControllerInputs::default(), self.clock.dt(), |_| {});
/*trace!(
"msgs {:?}: {:?} {:?}",
@ -131,7 +127,7 @@ impl BotClient {
.settings
.bot_logins
.iter()
.any(|x| &*x.username == &*username)
.any(|x| *x.username == *username)
{
continue;
}
@ -216,9 +212,6 @@ impl BotClient {
.cloned()
.collect();
for cred in creds.iter() {
let runtime = Arc::clone(&self.runtime);
let server = self.settings.server.clone();
let client = match self.bot_clients.get_mut(&cred.username) {
Some(c) => c,
None => {

View File

@ -27,16 +27,11 @@ impl Tui {
let handle = thread::spawn(move || {
thread::sleep(Duration::from_millis(20));
let mut readline = rustyline::Editor::<()>::new();
loop {
match readline.readline("\n\nbotclient> ") {
Ok(cmd) => {
let keep_going = Self::process_command(&cmd, &mut commands_s);
readline.add_history_entry(cmd);
if !keep_going {
break;
}
},
Err(_) => break,
while let Ok(cmd) = readline.readline("\n\nbotclient> ") {
let keep_going = Self::process_command(&cmd, &mut commands_s);
readline.add_history_entry(cmd);
if !keep_going {
break;
}
}
});
@ -69,7 +64,7 @@ impl Tui {
.about("Join the world with some random character")
.args(&[Arg::with_name("prefix").required(true)]),
)
.get_matches_from_safe(cmd.split(" "));
.get_matches_from_safe(cmd.split(' '));
use clap::ErrorKind::*;
match matches {
Ok(matches) => {

View File

@ -121,7 +121,6 @@ fn weapon_stats() -> Result<(), Box<dyn Error>> {
let poise_strength = tool.base_poise_strength(&msm, &[]).to_string();
let speed = tool.base_speed(&msm, &[]).to_string();
let crit_chance = tool.base_crit_chance(&msm, &[]).to_string();
let crit_mult = tool.base_crit_mult(&msm, &[]).to_string();
let equip_time = tool.equip_time(&msm, &[]).as_secs_f32().to_string();
let kind = get_tool_kind(&tool.kind);
let hands = get_tool_hands(&tool);
@ -136,7 +135,6 @@ fn weapon_stats() -> Result<(), Box<dyn Error>> {
&poise_strength,
&speed,
&crit_chance,
&crit_mult,
&equip_time,
item.description(),
])?;

View File

@ -1,4 +1,5 @@
#![deny(clippy::clone_on_ref_ptr)]
#![allow(clippy::expect_fun_call)]
use hashbrown::HashMap;
use ron::ser::{to_string_pretty, PrettyConfig};
@ -68,11 +69,8 @@ fn armor_stats() -> Result<(), Box<dyn Error>> {
{
match item.kind() {
comp::item::ItemKind::Armor(armor) => {
match armor.kind {
ArmorKind::Bag(_) => {
continue;
},
_ => {},
if let ArmorKind::Bag(_) = armor.kind {
continue;
}
if let Ok(ref record) = record {
@ -217,7 +215,7 @@ fn armor_stats() -> Result<(), Box<dyn Error>> {
.with_enumerate_arrays(true);
let mut path = ASSETS_PATH.clone();
for part in item.item_definition_id().split(".") {
for part in item.item_definition_id().split('.') {
path.push(part);
}
path.set_extension("ron");
@ -329,15 +327,6 @@ fn weapon_stats() -> Result<(), Box<dyn Error>> {
.parse()
.expect(&format!("Not a f32? {:?}", item.item_definition_id()));
let crit_mult: f32 = record
.get(headers["Crit Mult"])
.expect(&format!(
"Error unwrapping crit_mult for {:?}",
item.item_definition_id()
))
.parse()
.expect(&format!("Not a f32? {:?}", item.item_definition_id()));
let tool = comp::item::tool::Tool::new(
kind,
hands,
@ -346,7 +335,6 @@ fn weapon_stats() -> Result<(), Box<dyn Error>> {
poise_strength,
speed,
crit_chance,
crit_mult,
);
let quality = if let Some(quality_raw) = record.get(headers["Quality"])
@ -396,7 +384,7 @@ fn weapon_stats() -> Result<(), Box<dyn Error>> {
.with_enumerate_arrays(true);
let mut path = ASSETS_PATH.clone();
for part in item.item_definition_id().split(".") {
for part in item.item_definition_id().split('.') {
path.push(part);
}
path.set_extension("ron");
@ -432,41 +420,39 @@ fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
let mut items = Vec::<(f32, LootSpec)>::new();
for record in rdr.records() {
if let Ok(ref record) = record {
let item = match record.get(headers["Kind"]).expect("No loot specifier") {
"Item" => {
if let (Some(Ok(lower)), Some(Ok(upper))) = (
record.get(headers["Lower Amount"]).map(|a| a.parse()),
record.get(headers["Upper Amount"]).map(|a| a.parse()),
) {
LootSpec::ItemQuantity(
record.get(headers["Item"]).expect("No item").to_string(),
lower,
upper,
)
} else {
LootSpec::Item(record.get(headers["Item"]).expect("No item").to_string())
}
},
"LootTable" => LootSpec::LootTable(
record
.get(headers["Item"])
.expect("No loot table")
.to_string(),
),
a => panic!(
"Loot specifier kind must be either \"Item\" or \"LootTable\"\n{}",
a
),
};
let chance: f32 = record
.get(headers["Relative Chance"])
.expect("No chance for item in entry")
.parse()
.expect("Not an f32 for chance in entry");
items.push((chance, item));
}
for ref record in rdr.records().flatten() {
let item = match record.get(headers["Kind"]).expect("No loot specifier") {
"Item" => {
if let (Some(Ok(lower)), Some(Ok(upper))) = (
record.get(headers["Lower Amount"]).map(|a| a.parse()),
record.get(headers["Upper Amount"]).map(|a| a.parse()),
) {
LootSpec::ItemQuantity(
record.get(headers["Item"]).expect("No item").to_string(),
lower,
upper,
)
} else {
LootSpec::Item(record.get(headers["Item"]).expect("No item").to_string())
}
},
"LootTable" => LootSpec::LootTable(
record
.get(headers["Item"])
.expect("No loot table")
.to_string(),
),
a => panic!(
"Loot specifier kind must be either \"Item\" or \"LootTable\"\n{}",
a
),
};
let chance: f32 = record
.get(headers["Relative Chance"])
.expect("No chance for item in entry")
.parse()
.expect("Not an f32 for chance in entry");
items.push((chance, item));
}
let pretty_config = PrettyConfig::new()
@ -476,7 +462,7 @@ fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
let mut path = ASSETS_PATH.clone();
path.push("common");
path.push("loot_tables");
for part in loot_table.split(".") {
for part in loot_table.split('.') {
path.push(part);
}
path.set_extension("ron");
@ -514,7 +500,7 @@ Would you like to continue? (y/n)
> ",
)
.to_lowercase()
== "y".to_string()
== *"y"
{
if let Err(e) = armor_stats() {
println!("Error: {}\n", e)
@ -544,7 +530,7 @@ Would you like to continue? (y/n)
> ",
)
.to_lowercase()
== "y".to_string()
== *"y"
{
if let Err(e) = weapon_stats() {
println!("Error: {}\n", e)
@ -578,7 +564,7 @@ Would you like to continue? (y/n)
> ",
)
.to_lowercase()
== "y".to_string()
== *"y"
{
if let Err(e) = loot_table(&loot_table_name) {
println!("Error: {}\n", e)