Skip to content

Commit

Permalink
markdown shenanigans
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAlan404 committed Jun 28, 2024
1 parent 67ac42a commit e1e7deb
Show file tree
Hide file tree
Showing 14 changed files with 406 additions and 12 deletions.
39 changes: 36 additions & 3 deletions src/api/app/actions/markdown/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,46 @@ use std::sync::Arc;

use anyhow::Result;

use crate::api::app::App;
use crate::api::{app::App, models::{markdown::{MarkdownOptions, MarkdownOutput}, AddonMetadata, AddonMetadataSource}};

Check warning on line 5 in src/api/app/actions/markdown/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unused imports: `AddonMetadataSource`, `MarkdownOutput`

warning: unused imports: `AddonMetadataSource`, `MarkdownOutput` --> src/api/app/actions/markdown/mod.rs:5:65 | 5 | use crate::api::{app::App, models::{markdown::{MarkdownOptions, MarkdownOutput}, AddonMetadata, AddonMetadataSource}}; | ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default

impl App {
pub async fn render_markdown(self: Arc<Self>) -> Result<()> {
pub async fn get_markdown_options(&self) -> Option<MarkdownOptions> {

Check warning on line 8 in src/api/app/actions/markdown/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

methods `get_markdown_options`, `get_all_metadata`, `render_markdown_with`, and `render_markdown_and_save` are never used

warning: methods `get_markdown_options`, `get_all_metadata`, `render_markdown_with`, and `render_markdown_and_save` are never used --> src/api/app/actions/markdown/mod.rs:8:18 | 7 | impl App { | -------- methods in this implementation 8 | pub async fn get_markdown_options(&self) -> Option<MarkdownOptions> { | ^^^^^^^^^^^^^^^^^^^^ ... 16 | pub async fn get_all_metadata(self: Arc<Self>) -> Result<Vec<AddonMetadata>> { | ^^^^^^^^^^^^^^^^ ... 31 | pub async fn render_markdown_with(&self, metadata: Vec<AddonMetadata>) -> Result<String> { | ^^^^^^^^^^^^^^^^^^^^ ... 39 | pub async fn render_markdown_and_save(self: Arc<Self>) -> Result<()> { | ^^^^^^^^^^^^^^^^^^^^^^^^
if let Some((_, server)) = &*self.server.read().await {
Some(server.markdown.clone())
} else {
None
}
}

pub async fn get_all_metadata(self: Arc<Self>) -> Result<Vec<AddonMetadata>> {
let addons = self.collect_addons().await?;


let mut metadata = vec![];

for addon in &addons {
// TODO
if let Ok(m) = addon.resolve_metadata(&self).await {
metadata.push(m);
}
}

Ok(metadata)
}

pub async fn render_markdown_with(&self, metadata: Vec<AddonMetadata>) -> Result<String> {
let markdown_options = self.get_markdown_options().await.unwrap_or_default();

let table = markdown_options.render(metadata, markdown_options.output_type);

Ok(table.render(markdown_options.output_type))
}

pub async fn render_markdown_and_save(self: Arc<Self>) -> Result<()> {
let metadata = self.clone().get_all_metadata().await?;
let content = self.render_markdown_with(metadata).await?;

Check warning on line 41 in src/api/app/actions/markdown/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `content`

warning: unused variable: `content` --> src/api/app/actions/markdown/mod.rs:41:13 | 41 | let content = self.render_markdown_with(metadata).await?; | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_content`
let options = self.get_markdown_options().await.unwrap_or_default();

Check warning on line 42 in src/api/app/actions/markdown/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `options`

warning: unused variable: `options` --> src/api/app/actions/markdown/mod.rs:42:13 | 42 | let options = self.get_markdown_options().await.unwrap_or_default(); | ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_options`

// TODO

Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions src/api/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,6 @@ impl App {
hangar => HangarAPI,
jenkins => JenkinsAPI,
quilt => QuiltAPI,
spigot => SpigotAPI,
}
}
6 changes: 3 additions & 3 deletions src/api/models/addon/addon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ impl Addon {
AddonType::Url { url } => resolve_steps_for_url(app, url, None).await,
AddonType::Modrinth { id, version } => app.modrinth().resolve_steps(id, version).await,
AddonType::Curseforge { id, version } => Ok(vec![]),

Check warning on line 21 in src/api/models/addon/addon.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `version`

warning: unused variable: `version` --> src/api/models/addon/addon.rs:21:41 | 21 | AddonType::Curseforge { id, version } => Ok(vec![]), | ^^^^^^^ help: try ignoring the field: `version: _`

Check warning on line 21 in src/api/models/addon/addon.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `id`

warning: unused variable: `id` --> src/api/models/addon/addon.rs:21:37 | 21 | AddonType::Curseforge { id, version } => Ok(vec![]), | ^^ help: try ignoring the field: `id: _`
AddonType::Spigot { id, version } => todo!(),
AddonType::Hangar { id, version } => todo!(),
AddonType::Spigot { id, version } => app.spigot().resolve_steps(id, version).await,
AddonType::Hangar { id, version } => app.hangar().resolve_steps(id, version).await,
AddonType::GithubRelease { repo, version, filename } => app.github().resolve_steps(repo, version, filename).await,
AddonType::Jenkins { url, job, build, artifact } => todo!(),
AddonType::Jenkins { url, job, build, artifact } => app.jenkins().resolve_steps(url, job, build, artifact, None).await,
AddonType::MavenArtifact { url, group, artifact, version, filename } => app.maven().resolve_steps(url, group, artifact, version, filename).await,
}
}
Expand Down
36 changes: 33 additions & 3 deletions src/api/models/addon/addon_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::Result;
use anyhow::{bail, Result};
use serde::{Deserialize, Serialize};

use crate::api::{app::App, sources::{jenkins::jenkins_job_url, maven::maven_artifact_url}, utils::url::get_filename_from_url};
Expand All @@ -19,6 +19,27 @@ pub enum AddonMetadataSource {
}

impl AddonMetadataSource {
pub fn all() -> Vec<Self> {

Check warning on line 22 in src/api/models/addon/addon_metadata.rs

View workflow job for this annotation

GitHub Actions / clippy

associated items `all`, `get_markdown_header`, `into_str`, `markdown_tag`, `html`, and `icon_url` are never used

warning: associated items `all`, `get_markdown_header`, `into_str`, `markdown_tag`, `html`, and `icon_url` are never used --> src/api/models/addon/addon_metadata.rs:22:12 | 21 | impl AddonMetadataSource { | ------------------------ associated items in this implementation 22 | pub fn all() -> Vec<Self> { | ^^^ ... 35 | pub fn get_markdown_header() -> String { | ^^^^^^^^^^^^^^^^^^^ ... 43 | pub fn into_str(&self) -> &'static str { | ^^^^^^^^ ... 56 | pub fn markdown_tag(&self) -> String { | ^^^^^^^^^^^^ ... 60 | pub fn html(&self) -> String { | ^^^^ ... 64 | pub fn icon_url(&self) -> String { | ^^^^^^^^
vec![
AddonMetadataSource::Modrinth,
AddonMetadataSource::Hangar,
AddonMetadataSource::Spigot,
AddonMetadataSource::Other,
AddonMetadataSource::Github,
AddonMetadataSource::Jenkins,
AddonMetadataSource::Maven,
AddonMetadataSource::Curseforge,
]
}

pub fn get_markdown_header() -> String {
Self::all()
.into_iter()
.map(|src| format!("[{}]: {}", src.into_str(), src.icon_url()))
.collect::<Vec<_>>()
.join("\n")
}

pub fn into_str(&self) -> &'static str {

Check warning on line 43 in src/api/models/addon/addon_metadata.rs

View workflow job for this annotation

GitHub Actions / clippy

this argument (1 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)

warning: this argument (1 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) --> src/api/models/addon/addon_metadata.rs:43:21 | 43 | pub fn into_str(&self) -> &'static str { | ^^^^^ help: consider passing by value instead: `self` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref

Check failure on line 43 in src/api/models/addon/addon_metadata.rs

View workflow job for this annotation

GitHub Actions / clippy

methods called `into_*` usually take `self` by value

error: methods called `into_*` usually take `self` by value --> src/api/models/addon/addon_metadata.rs:43:21 | 43 | pub fn into_str(&self) -> &'static str { | ^^^^^ | = help: consider choosing a less ambiguous name = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention = note: `-D clippy::wrong-self-convention` implied by `-D clippy::all` = help: to override `-D clippy::all` add `#[allow(clippy::wrong_self_convention)]`
match self {
AddonMetadataSource::Modrinth => "modrinth",
Expand All @@ -32,8 +53,17 @@ impl AddonMetadataSource {
}
}

pub fn markdown_tag(&self) -> String {

Check warning on line 56 in src/api/models/addon/addon_metadata.rs

View workflow job for this annotation

GitHub Actions / clippy

this argument (1 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)

warning: this argument (1 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) --> src/api/models/addon/addon_metadata.rs:56:25 | 56 | pub fn markdown_tag(&self) -> String { | ^^^^^ help: consider passing by value instead: `self` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref
format!("![{}]", self.into_str())
}

pub fn html(&self) -> String {

Check warning on line 60 in src/api/models/addon/addon_metadata.rs

View workflow job for this annotation

GitHub Actions / clippy

this argument (1 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)

warning: this argument (1 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) --> src/api/models/addon/addon_metadata.rs:60:17 | 60 | pub fn html(&self) -> String { | ^^^^^ help: consider passing by value instead: `self` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref
format!("<img src='{}'>", self.icon_url())
}

pub fn icon_url(&self) -> String {

Check warning on line 64 in src/api/models/addon/addon_metadata.rs

View workflow job for this annotation

GitHub Actions / clippy

this argument (1 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)

warning: this argument (1 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) --> src/api/models/addon/addon_metadata.rs:64:21 | 64 | pub fn icon_url(&self) -> String { | ^^^^^ help: consider passing by value instead: `self` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref
format!("https://raw.githubusercontent.com/ParadigmMC/mcman/main/res/icons/{}.png", self.into_str())
// TODO !!!!!!!!!!!!!!!!!!!!!
format!("https://raw.githubusercontent.com/ParadigmMC/mcman/v2/res/icons/{}.png", self.into_str())
}
}

Expand Down Expand Up @@ -67,7 +97,7 @@ impl Addon {
source: AddonMetadataSource::Modrinth,
})
},
AddonType::Curseforge { id, version } => todo!(),
AddonType::Curseforge { id, version } => bail!("Unimplemented"),

Check warning on line 100 in src/api/models/addon/addon_metadata.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `version`

warning: unused variable: `version` --> src/api/models/addon/addon_metadata.rs:100:41 | 100 | AddonType::Curseforge { id, version } => bail!("Unimplemented"), | ^^^^^^^ help: try ignoring the field: `version: _`

Check warning on line 100 in src/api/models/addon/addon_metadata.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `id`

warning: unused variable: `id` --> src/api/models/addon/addon_metadata.rs:100:37 | 100 | AddonType::Curseforge { id, version } => bail!("Unimplemented"), | ^^ help: try ignoring the field: `id: _`
AddonType::Spigot { id, version } => todo!(),

Check warning on line 101 in src/api/models/addon/addon_metadata.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `version`

warning: unused variable: `version` --> src/api/models/addon/addon_metadata.rs:101:37 | 101 | AddonType::Spigot { id, version } => todo!(), | ^^^^^^^ help: try ignoring the field: `version: _`

Check warning on line 101 in src/api/models/addon/addon_metadata.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `id`

warning: unused variable: `id` --> src/api/models/addon/addon_metadata.rs:101:33 | 101 | AddonType::Spigot { id, version } => todo!(), | ^^ help: try ignoring the field: `id: _`
AddonType::Hangar { id, version } => {
let proj = app.hangar().fetch_project(id).await?;
Expand Down
32 changes: 31 additions & 1 deletion src/api/models/markdown/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
use std::collections::HashMap;

use serde::{Deserialize, Serialize};

pub mod render;

#[derive(Debug, Clone, Copy, Default, Deserialize, Serialize, PartialEq)]
pub enum MarkdownOutput {
#[default]
ASCII,

Check failure on line 10 in src/api/models/markdown/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

name `ASCII` contains a capitalized acronym

error: name `ASCII` contains a capitalized acronym --> src/api/models/markdown/mod.rs:10:5 | 10 | ASCII, | ^^^^^ help: consider making the acronym lowercase, except the initial letter (notice the capitalization): `Ascii` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms = note: `-D clippy::upper-case-acronyms` implied by `-D clippy::all` = help: to override `-D clippy::all` add `#[allow(clippy::upper_case_acronyms)]`
HTML,

Check failure on line 11 in src/api/models/markdown/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

name `HTML` contains a capitalized acronym

error: name `HTML` contains a capitalized acronym --> src/api/models/markdown/mod.rs:11:5 | 11 | HTML, | ^^^^ help: consider making the acronym lowercase, except the initial letter: `Html` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#upper_case_acronyms
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct MarkdownOptions {
pub files: Vec<String>,
pub columns: Vec<MdColumn>,
pub titles: HashMap<MdColumn, String>,
pub name_includes_link: bool,
pub sort_by: MdSort,
pub output_type: MarkdownOutput,
}

impl Default for MarkdownOptions {
Expand All @@ -17,18 +31,34 @@ impl Default for MarkdownOptions {
MdColumn::Description,
MdColumn::Version,
],
name_includes_link: true,
titles: HashMap::new(),
sort_by: MdSort::default(),
output_type: MarkdownOutput::default(),
}
}
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash)]
#[serde(rename_all = "lowercase")]
pub enum MdColumn {
Icon,
Name,
Description,
Version,
Link,
}

impl ToString for MdColumn {
fn to_string(&self) -> String {
match self {
MdColumn::Icon => String::from("."),
MdColumn::Name => String::from("Name"),
MdColumn::Description => String::from("Description"),
MdColumn::Version => String::from("Version"),
MdColumn::Link => String::from("Link"),
}
}
}

Check failure on line 62 in src/api/models/markdown/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

direct implementation of `ToString`

error: direct implementation of `ToString` --> src/api/models/markdown/mod.rs:52:1 | 52 | / impl ToString for MdColumn { 53 | | fn to_string(&self) -> String { 54 | | match self { 55 | | MdColumn::Icon => String::from("."), ... | 61 | | } 62 | | } | |_^ | = help: prefer implementing `Display` instead = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#to_string_trait_impl


Expand Down
46 changes: 46 additions & 0 deletions src/api/models/markdown/render.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use crate::api::{models::AddonMetadata, utils::markdown::{HeaderAlignment, MarkdownHeader, MarkdownTable}};

use super::{MarkdownOptions, MarkdownOutput, MdColumn};

impl MarkdownOptions {
pub fn render(&self, list: Vec<AddonMetadata>, output: MarkdownOutput) -> MarkdownTable {

Check warning on line 6 in src/api/models/markdown/render.rs

View workflow job for this annotation

GitHub Actions / clippy

this argument is passed by value, but not consumed in the function body

warning: this argument is passed by value, but not consumed in the function body --> src/api/models/markdown/render.rs:6:32 | 6 | pub fn render(&self, list: Vec<AddonMetadata>, output: MarkdownOutput) -> MarkdownTable { | ^^^^^^^^^^^^^^^^^^ help: consider changing the type to: `&[AddonMetadata]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value = note: `-W clippy::needless-pass-by-value` implied by `-W clippy::pedantic` = help: to override `-W clippy::pedantic` add `#[allow(clippy::needless_pass_by_value)]`

Check warning on line 6 in src/api/models/markdown/render.rs

View workflow job for this annotation

GitHub Actions / clippy

method `render` is never used

warning: method `render` is never used --> src/api/models/markdown/render.rs:6:12 | 5 | impl MarkdownOptions { | -------------------- method in this implementation 6 | pub fn render(&self, list: Vec<AddonMetadata>, output: MarkdownOutput) -> MarkdownTable { | ^^^^^^
let mut table = MarkdownTable::new();

for column in &self.columns {
table.headers.push(MarkdownHeader(self.titles.get(column).cloned().unwrap_or_else(|| column.to_string()), HeaderAlignment::default()));
}

for meta in &list {
let mut row = vec![];

for column in &self.columns {
match column {
MdColumn::Name => row.push(if self.name_includes_link {
if let Some(link) = &meta.link {
match output {
MarkdownOutput::ASCII => format!("[{}]({})", meta.name, link),
MarkdownOutput::HTML => format!("<a href={}>{}</a>", link, meta.name),
}
} else {
meta.name.clone()
}
} else {
meta.name.clone()
}),
MdColumn::Description => row.push(meta.description.clone().unwrap_or_default()),
MdColumn::Link => row.push(meta.link.clone().unwrap_or_default()),
MdColumn::Version => row.push(meta.version.clone().unwrap_or_default()),
MdColumn::Icon => row.push(match output {
MarkdownOutput::ASCII => meta.source.markdown_tag(),
MarkdownOutput::HTML => meta.source.html(),
_ => meta.source.into_str().to_owned(),

Check warning on line 36 in src/api/models/markdown/render.rs

View workflow job for this annotation

GitHub Actions / clippy

unreachable pattern

warning: unreachable pattern --> src/api/models/markdown/render.rs:36:25 | 36 | _ => meta.source.into_str().to_owned(), | ^ | = note: `#[warn(unreachable_patterns)]` on by default
}),
}
}

table.add_row(row);
}

table
}
}
35 changes: 33 additions & 2 deletions src/api/models/packwiz/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
mod packwiz_mod;
mod packwiz_pack;

use std::path::Path;
use std::path::{Path, PathBuf};

Check warning on line 4 in src/api/models/packwiz/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `Path`

warning: unused import: `Path` --> src/api/models/packwiz/mod.rs:4:17 | 4 | use std::path::{Path, PathBuf}; | ^^^^

use anyhow::{bail, Result};
pub use packwiz_mod::*;
pub use packwiz_pack::*;

use crate::api::{app::App, models::AddonType, utils::accessor::Accessor};
use crate::api::{app::App, models::AddonType, step::Step, utils::{accessor::Accessor, url::get_filename_from_url}};

Check warning on line 10 in src/api/models/packwiz/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `url::get_filename_from_url`

warning: unused import: `url::get_filename_from_url` --> src/api/models/packwiz/mod.rs:10:87 | 10 | use crate::api::{app::App, models::AddonType, step::Step, utils::{accessor::Accessor, url::get_filename_from_url}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^

pub static PACK_TOML: &str = "pack.toml";

Expand All @@ -31,7 +31,38 @@ pub async fn resolve_packwiz_addons(app: &App, mut accessor: Accessor) -> Result
Ok(addons)
}

impl PackwizModUpdate {
pub fn from_addon_type(addon_type: &AddonType) -> Result<Option<Self>> {

Check warning on line 35 in src/api/models/packwiz/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

associated function `from_addon_type` is never used

warning: associated function `from_addon_type` is never used --> src/api/models/packwiz/mod.rs:35:12 | 34 | impl PackwizModUpdate { | --------------------- associated function in this implementation 35 | pub fn from_addon_type(addon_type: &AddonType) -> Result<Option<Self>> { | ^^^^^^^^^^^^^^^
match addon_type.clone() {
AddonType::Modrinth { id, version } => Ok(Some(Self::Modrinth { mod_id: id, version })),
AddonType::Curseforge { id, version } => Ok(Some(Self::Curseforge { file_id: version.parse()?, project_id: id.parse()? })),
_ => Ok(None),
}
}
}

impl PackwizModDownload {
pub async fn from_steps(steps: &Vec<Step>) -> Self {

Check failure on line 45 in src/api/models/packwiz/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

writing `&Vec` instead of `&[_]` involves a new object where a slice will do

error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do --> src/api/models/packwiz/mod.rs:45:36 | 45 | pub async fn from_steps(steps: &Vec<Step>) -> Self { | ^^^^^^^^^^ help: change this to: `&[Step]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg

Check warning on line 45 in src/api/models/packwiz/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

associated function `from_steps` is never used

warning: associated function `from_steps` is never used --> src/api/models/packwiz/mod.rs:45:18 | 44 | impl PackwizModDownload { | ----------------------- associated function in this implementation 45 | pub async fn from_steps(steps: &Vec<Step>) -> Self { | ^^^^^^^^^^

Check warning on line 45 in src/api/models/packwiz/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `steps`

warning: unused variable: `steps` --> src/api/models/packwiz/mod.rs:45:29 | 45 | pub async fn from_steps(steps: &Vec<Step>) -> Self { | ^^^^^ help: if this is intentional, prefix it with an underscore: `_steps`
todo!()
}

Check warning on line 47 in src/api/models/packwiz/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unused `async` for function with no await statements

warning: unused `async` for function with no await statements --> src/api/models/packwiz/mod.rs:45:5 | 45 | / pub async fn from_steps(steps: &Vec<Step>) -> Self { 46 | | todo!() 47 | | } | |_____^ | = help: consider removing the `async` from this function = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_async
}

impl PackwizMod {
// TODO: incomplete
pub async fn from_addon(app: &App, addon: &Addon) -> Result<(PathBuf, Self)> {

Check warning on line 52 in src/api/models/packwiz/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

associated function `from_addon` is never used

warning: associated function `from_addon` is never used --> src/api/models/packwiz/mod.rs:52:18 | 50 | impl PackwizMod { | --------------- associated function in this implementation 51 | // TODO: incomplete 52 | pub async fn from_addon(app: &App, addon: &Addon) -> Result<(PathBuf, Self)> { | ^^^^^^^^^^
let steps = addon.resolve_steps(app).await?;

Check warning on line 53 in src/api/models/packwiz/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `steps`

warning: unused variable: `steps` --> src/api/models/packwiz/mod.rs:53:13 | 53 | let steps = addon.resolve_steps(app).await?; | ^^^^^ help: if this is intentional, prefix it with an underscore: `_steps`

let update = PackwizModUpdate::from_addon_type(&addon.addon_type)?;

let m = Self {
update,
side: addon.environment.unwrap_or_default(),
..Default::default()
};

Ok((addon.target.to_path(), m))
}

pub async fn into_addon(&self, app: &App, target: AddonTarget) -> Result<Addon> {

Check failure on line 66 in src/api/models/packwiz/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

methods called `into_*` usually take `self` by value

error: methods called `into_*` usually take `self` by value --> src/api/models/packwiz/mod.rs:66:29 | 66 | pub async fn into_addon(&self, app: &App, target: AddonTarget) -> Result<Addon> { | ^^^^^ | = help: consider choosing a less ambiguous name = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention

Check warning on line 66 in src/api/models/packwiz/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `app`

warning: unused variable: `app` --> src/api/models/packwiz/mod.rs:66:36 | 66 | pub async fn into_addon(&self, app: &App, target: AddonTarget) -> Result<Addon> { | ^^^ help: if this is intentional, prefix it with an underscore: `_app`
let addon_type = if let Some(update) = &self.update {
match update {
Expand Down
Loading

0 comments on commit e1e7deb

Please sign in to comment.