clippy: Deny and fix `index_slicing`
This commit is contained in:
parent
0855af00a9
commit
4c1b7fcd80
|
|
@ -81,6 +81,7 @@ radicle-surf = "0.26.0"
|
||||||
[workspace.lints]
|
[workspace.lints]
|
||||||
clippy.type_complexity = "allow"
|
clippy.type_complexity = "allow"
|
||||||
clippy.enum_variant_names = "allow"
|
clippy.enum_variant_names = "allow"
|
||||||
|
clippy.indexing_slicing = "deny"
|
||||||
clippy.fallible_impl_from = "deny"
|
clippy.fallible_impl_from = "deny"
|
||||||
clippy.wildcard_enum_match_arm = "deny"
|
clippy.wildcard_enum_match_arm = "deny"
|
||||||
clippy.unneeded_field_pattern = "deny"
|
clippy.unneeded_field_pattern = "deny"
|
||||||
|
|
|
||||||
|
|
@ -210,6 +210,7 @@ where
|
||||||
|
|
||||||
chunks.map(|chunk| {
|
chunks.map(|chunk| {
|
||||||
// Slice accesses will not panic, guaranteed by `chunks_exact(2)`.
|
// Slice accesses will not panic, guaranteed by `chunks_exact(2)`.
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
Embed {
|
Embed {
|
||||||
name: chunk[0].to_string(),
|
name: chunk[0].to_string(),
|
||||||
content: EmbedContent::from(T::from(chunk[1].clone())),
|
content: EmbedContent::from(T::from(chunk[1].clone())),
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,7 @@ pub(super) fn parse_many_upserts(
|
||||||
|
|
||||||
chunks.map(|chunk| {
|
chunks.map(|chunk| {
|
||||||
// Slice accesses will not panic, guaranteed by `chunks_exact(3)`.
|
// Slice accesses will not panic, guaranteed by `chunks_exact(3)`.
|
||||||
|
#[allow(clippy::indexing_slicing)]
|
||||||
Ok(PayloadUpsert {
|
Ok(PayloadUpsert {
|
||||||
id: PayloadId::from_str(&chunk[0])?,
|
id: PayloadId::from_str(&chunk[0])?,
|
||||||
key: chunk[1].to_owned(),
|
key: chunk[1].to_owned(),
|
||||||
|
|
|
||||||
|
|
@ -537,14 +537,14 @@ impl ToPretty for Modification {
|
||||||
match self {
|
match self {
|
||||||
Modification::Deletion(diff::Deletion { line, line_no }) => {
|
Modification::Deletion(diff::Deletion { line, line_no }) => {
|
||||||
if let Some(lines) = &blobs.old.as_ref() {
|
if let Some(lines) = &blobs.old.as_ref() {
|
||||||
lines[*line_no as usize - 1].clone()
|
lines.get(*line_no as usize - 1).unwrap().clone()
|
||||||
} else {
|
} else {
|
||||||
term::Line::new(String::from_utf8_lossy(line.as_bytes()).as_ref())
|
term::Line::new(String::from_utf8_lossy(line.as_bytes()).as_ref())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Modification::Addition(diff::Addition { line, line_no }) => {
|
Modification::Addition(diff::Addition { line, line_no }) => {
|
||||||
if let Some(lines) = &blobs.new.as_ref() {
|
if let Some(lines) = &blobs.new.as_ref() {
|
||||||
lines[*line_no as usize - 1].clone()
|
lines.get(*line_no as usize - 1).unwrap().clone()
|
||||||
} else {
|
} else {
|
||||||
term::Line::new(String::from_utf8_lossy(line.as_bytes()).as_ref())
|
term::Line::new(String::from_utf8_lossy(line.as_bytes()).as_ref())
|
||||||
}
|
}
|
||||||
|
|
@ -554,7 +554,7 @@ impl ToPretty for Modification {
|
||||||
} => {
|
} => {
|
||||||
// Nb. we can check in the old or the new blob, we choose the new.
|
// Nb. we can check in the old or the new blob, we choose the new.
|
||||||
if let Some(lines) = &blobs.new.as_ref() {
|
if let Some(lines) = &blobs.new.as_ref() {
|
||||||
lines[*line_no_new as usize - 1].clone()
|
lines.get(*line_no_new as usize - 1).unwrap().clone()
|
||||||
} else {
|
} else {
|
||||||
term::Line::new(String::from_utf8_lossy(line.as_bytes()).as_ref())
|
term::Line::new(String::from_utf8_lossy(line.as_bytes()).as_ref())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,9 +145,11 @@ impl Builder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ts::HighlightEvent::HighlightStart(h) => {
|
ts::HighlightEvent::HighlightStart(h) => {
|
||||||
let name = HIGHLIGHTS[h.0];
|
let color = HIGHLIGHTS
|
||||||
let style =
|
.get(h.0)
|
||||||
term::Style::default().fg(theme.highlight(name).unwrap_or_default());
|
.and_then(|name| theme.highlight(name))
|
||||||
|
.unwrap_or_default();
|
||||||
|
let style = term::Style::default().fg(color);
|
||||||
|
|
||||||
self.advance();
|
self.advance();
|
||||||
self.styles.push(style);
|
self.styles.push(style);
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ pub fn comment_select(issue: &Issue) -> anyhow::Result<(&CommentId, &Comment)> {
|
||||||
(0..comments.len()).collect(),
|
(0..comments.len()).collect(),
|
||||||
)
|
)
|
||||||
.with_render_config(*CONFIG)
|
.with_render_config(*CONFIG)
|
||||||
.with_formatter(&|i| comments[i.index].1.body().to_owned())
|
.with_formatter(&|i| comments.get(i.index).unwrap().1.body().to_owned())
|
||||||
.prompt()?;
|
.prompt()?;
|
||||||
|
|
||||||
comments
|
comments
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,7 @@ fn rad_config() {
|
||||||
let mut environment = Environment::new();
|
let mut environment = Environment::new();
|
||||||
let alias = Alias::new("alice");
|
let alias = Alias::new("alice");
|
||||||
let profile = environment.profile_with(profile::Config {
|
let profile = environment.profile_with(profile::Config {
|
||||||
preferred_seeds: vec![RADICLE_NODE_BOOTSTRAP_IRIS.clone()[0].clone()],
|
preferred_seeds: vec![RADICLE_NODE_BOOTSTRAP_IRIS.clone().first().unwrap().clone()],
|
||||||
..profile::Config::new(alias)
|
..profile::Config::new(alias)
|
||||||
});
|
});
|
||||||
let working = tempfile::tempdir().unwrap();
|
let working = tempfile::tempdir().unwrap();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue