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]
|
||||
clippy.type_complexity = "allow"
|
||||
clippy.enum_variant_names = "allow"
|
||||
clippy.indexing_slicing = "deny"
|
||||
clippy.fallible_impl_from = "deny"
|
||||
clippy.wildcard_enum_match_arm = "deny"
|
||||
clippy.unneeded_field_pattern = "deny"
|
||||
|
|
|
|||
|
|
@ -210,6 +210,7 @@ where
|
|||
|
||||
chunks.map(|chunk| {
|
||||
// Slice accesses will not panic, guaranteed by `chunks_exact(2)`.
|
||||
#[allow(clippy::indexing_slicing)]
|
||||
Embed {
|
||||
name: chunk[0].to_string(),
|
||||
content: EmbedContent::from(T::from(chunk[1].clone())),
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ pub(super) fn parse_many_upserts(
|
|||
|
||||
chunks.map(|chunk| {
|
||||
// Slice accesses will not panic, guaranteed by `chunks_exact(3)`.
|
||||
#[allow(clippy::indexing_slicing)]
|
||||
Ok(PayloadUpsert {
|
||||
id: PayloadId::from_str(&chunk[0])?,
|
||||
key: chunk[1].to_owned(),
|
||||
|
|
|
|||
|
|
@ -537,14 +537,14 @@ impl ToPretty for Modification {
|
|||
match self {
|
||||
Modification::Deletion(diff::Deletion { line, line_no }) => {
|
||||
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 {
|
||||
term::Line::new(String::from_utf8_lossy(line.as_bytes()).as_ref())
|
||||
}
|
||||
}
|
||||
Modification::Addition(diff::Addition { line, line_no }) => {
|
||||
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 {
|
||||
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.
|
||||
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 {
|
||||
term::Line::new(String::from_utf8_lossy(line.as_bytes()).as_ref())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,9 +145,11 @@ impl Builder {
|
|||
}
|
||||
}
|
||||
ts::HighlightEvent::HighlightStart(h) => {
|
||||
let name = HIGHLIGHTS[h.0];
|
||||
let style =
|
||||
term::Style::default().fg(theme.highlight(name).unwrap_or_default());
|
||||
let color = HIGHLIGHTS
|
||||
.get(h.0)
|
||||
.and_then(|name| theme.highlight(name))
|
||||
.unwrap_or_default();
|
||||
let style = term::Style::default().fg(color);
|
||||
|
||||
self.advance();
|
||||
self.styles.push(style);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ pub fn comment_select(issue: &Issue) -> anyhow::Result<(&CommentId, &Comment)> {
|
|||
(0..comments.len()).collect(),
|
||||
)
|
||||
.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()?;
|
||||
|
||||
comments
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ fn rad_config() {
|
|||
let mut environment = Environment::new();
|
||||
let alias = Alias::new("alice");
|
||||
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)
|
||||
});
|
||||
let working = tempfile::tempdir().unwrap();
|
||||
|
|
|
|||
Loading…
Reference in New Issue