Skip to content

Commit

Permalink
fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenleadbeater committed Oct 28, 2024
1 parent ef33ec9 commit b2d77f6
Show file tree
Hide file tree
Showing 44 changed files with 127 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/api/api_models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ pub struct Artist {

impl WithImages for Artist {
fn images(&self) -> &[Image] {
#[allow(clippy::manual_unwrap_or_default)]
if let Some(ref images) = self.images {
images
} else {
Expand Down
8 changes: 4 additions & 4 deletions src/api/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub enum CacheError {
pub type ETag = String;

pub enum CacheFile {
Fresh(Vec<u8>, Option<ETag>),
Fresh(Vec<u8>),
Expired(Vec<u8>, Option<ETag>),
None,
}
Expand Down Expand Up @@ -138,7 +138,7 @@ impl CacheManager {
let (file, expiry) = join!(fs::read(&path), self.read_expiry_file(resource));

match (file, policy) {
(Ok(buf), CachePolicy::IgnoreExpiry) => Ok(CacheFile::Fresh(buf, None)),
(Ok(buf), CachePolicy::IgnoreExpiry) => Ok(CacheFile::Fresh(buf)),
(Ok(buf), CachePolicy::Revalidate) => {
let expiry = expiry.unwrap_or(CacheExpiry::Never);
let etag = expiry.etag().cloned();
Expand All @@ -150,7 +150,7 @@ impl CacheManager {
Ok(if expiry.is_expired() {
CacheFile::Expired(buf, etag)
} else {
CacheFile::Fresh(buf, etag)
CacheFile::Fresh(buf)
})
}
(_, CachePolicy::IgnoreCached) => Ok(CacheFile::None),
Expand Down Expand Up @@ -260,7 +260,7 @@ impl CacheManager {
{
let file = self.read_cache_file(resource, policy).await?;
match file {
CacheFile::Fresh(buf, _) => Ok(buf),
CacheFile::Fresh(buf) => Ok(buf),
CacheFile::Expired(buf, etag) => match fetch(etag).await? {
FetchResult::NotModified(expiry) => {
let meta = self.cache_meta_path(resource);
Expand Down
1 change: 1 addition & 0 deletions src/api/cached_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub trait SpotifyApiClient {

fn player_resume(&self, device_id: String) -> BoxFuture<SpotifyResult<()>>;

#[allow(dead_code)]
fn player_next(&self, device_id: String) -> BoxFuture<SpotifyResult<()>>;

fn player_seek(&self, device_id: String, pos: usize) -> BoxFuture<SpotifyResult<()>>;
Expand Down
5 changes: 4 additions & 1 deletion src/api/oauth2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,12 @@ pub enum OAuthError {
#[derive(Debug)]
pub struct OAuthToken {
pub access_token: String,
#[allow(dead_code)]
pub refresh_token: String,
pub expires_at: Instant,
#[allow(dead_code)]
pub token_type: String,
#[allow(dead_code)]
pub scopes: Vec<String>,
}

Expand Down Expand Up @@ -205,7 +208,7 @@ pub fn get_access_token(
if let Err(err) = open::that(auth_url.to_string()) {
eprintln!(
"An error occurred when opening '{}': {}",
auth_url.to_string(),
auth_url,
err
)
}
Expand Down
6 changes: 6 additions & 0 deletions src/app/components/album/album.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ glib::wrapper! {
pub struct AlbumWidget(ObjectSubclass<imp::AlbumWidget>) @extends gtk::Widget, libadwaita::Bin;
}

impl Default for AlbumWidget {
fn default() -> Self {
Self::new()
}
}

impl AlbumWidget {
pub fn new() -> Self {
display_add_css_provider(resource!("/components/album.css"));
Expand Down
1 change: 1 addition & 0 deletions src/app/components/album/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#[allow(clippy::module_inception)]
mod album;
pub use album::AlbumWidget;
6 changes: 6 additions & 0 deletions src/app/components/artist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ glib::wrapper! {
pub struct ArtistWidget(ObjectSubclass<imp::ArtistWidget>) @extends gtk::Widget, gtk::Box;
}

impl Default for ArtistWidget {
fn default() -> Self {
Self::new()
}
}

impl ArtistWidget {
pub fn new() -> Self {
glib::Object::new()
Expand Down
1 change: 1 addition & 0 deletions src/app/components/artist_details/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod artist_details;
pub use artist_details::*;

Expand Down
6 changes: 6 additions & 0 deletions src/app/components/details/album_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ glib::wrapper! {
pub struct AlbumHeaderWidget(ObjectSubclass<imp::AlbumHeaderWidget>) @extends gtk::Widget, gtk::Box;
}

impl Default for AlbumHeaderWidget {
fn default() -> Self {
Self::new()
}
}

impl AlbumHeaderWidget {
pub fn new() -> Self {
glib::Object::new()
Expand Down
1 change: 1 addition & 0 deletions src/app/components/details/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod album_header;
#[allow(clippy::module_inception)]
mod details;
mod details_model;
mod release_details;
Expand Down
6 changes: 6 additions & 0 deletions src/app/components/details/release_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ glib::wrapper! {
pub struct ReleaseDetailsWindow(ObjectSubclass<imp::ReleaseDetailsWindow>) @extends gtk::Widget, libadwaita::Window, libadwaita::PreferencesWindow;
}

impl Default for ReleaseDetailsWindow {
fn default() -> Self {
Self::new()
}
}

impl ReleaseDetailsWindow {
pub fn new() -> Self {
glib::Object::new()
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/device_selector/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl DeviceSelectorWidget {

for device in devices {
let check = gtk::CheckButton::builder()
.action_name(&format!("{}.{}", ACTIONS, CONNECT_ACTION))
.action_name(format!("{}.{}", ACTIONS, CONNECT_ACTION))
.action_target(&Some(&device.id).to_variant())
.group(&*widget.this_device_button)
.label(&device.label)
Expand Down
6 changes: 6 additions & 0 deletions src/app/components/headerbar/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ glib::wrapper! {
pub struct HeaderBarWidget(ObjectSubclass<imp::HeaderBarWidget>) @extends gtk::Widget, libadwaita::Bin;
}

impl Default for HeaderBarWidget {
fn default() -> Self {
Self::new()
}
}

impl HeaderBarWidget {
pub fn new() -> Self {
glib::Object::new()
Expand Down
6 changes: 6 additions & 0 deletions src/app/components/library/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ glib::wrapper! {
pub struct LibraryWidget(ObjectSubclass<imp::LibraryWidget>) @extends gtk::Widget, gtk::Box;
}

impl Default for LibraryWidget {
fn default() -> Self {
Self::new()
}
}

impl LibraryWidget {
pub fn new() -> Self {
glib::Object::new()
Expand Down
1 change: 1 addition & 0 deletions src/app/components/library/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod library;
mod library_model;

Expand Down
6 changes: 6 additions & 0 deletions src/app/components/login/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ glib::wrapper! {
pub struct LoginWindow(ObjectSubclass<imp::LoginWindow>) @extends gtk::Widget, libadwaita::Window;
}

impl Default for LoginWindow {
fn default() -> Self {
Self::new()
}
}

impl LoginWindow {
pub fn new() -> Self {
glib::Object::new()
Expand Down
1 change: 1 addition & 0 deletions src/app/components/login/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod login;
mod login_model;

Expand Down
1 change: 1 addition & 0 deletions src/app/components/navigation/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod navigation;
pub use navigation::*;

Expand Down
1 change: 1 addition & 0 deletions src/app/components/now_playing/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod now_playing;
pub use now_playing::*;

Expand Down
2 changes: 1 addition & 1 deletion src/app/components/playlist/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#[allow(clippy::module_inception)]
mod playlist;
pub use playlist::*;

mod song;
pub use song::*;

mod song_actions;
pub use song_actions::*;
6 changes: 6 additions & 0 deletions src/app/components/playlist/song.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ glib::wrapper! {
pub struct SongWidget(ObjectSubclass<imp::SongWidget>) @extends gtk::Widget, gtk::Grid;
}

impl Default for SongWidget {
fn default() -> Self {
Self::new()
}
}

impl SongWidget {
pub fn new() -> Self {
display_add_css_provider(resource!("/components/song.css"));
Expand Down
1 change: 1 addition & 0 deletions src/app/components/playlist_details/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod playlist_details;
mod playlist_details_model;
mod playlist_header;
Expand Down
6 changes: 6 additions & 0 deletions src/app/components/playlist_details/playlist_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ glib::wrapper! {
pub struct PlaylistHeaderWidget(ObjectSubclass<imp::PlaylistHeaderWidget>) @extends gtk::Widget, gtk::Box;
}

impl Default for PlaylistHeaderWidget {
fn default() -> Self {
Self::new()
}
}

impl PlaylistHeaderWidget {
pub fn new() -> Self {
glib::Object::new()
Expand Down
6 changes: 6 additions & 0 deletions src/app/components/playlist_details/playlist_headerbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ glib::wrapper! {
pub struct PlaylistHeaderBarWidget(ObjectSubclass<imp::PlaylistHeaderBarWidget>) @extends gtk::Widget, libadwaita::Bin;
}

impl Default for PlaylistHeaderBarWidget {
fn default() -> Self {
Self::new()
}
}

impl PlaylistHeaderBarWidget {
pub fn new() -> Self {
glib::Object::new()
Expand Down
1 change: 1 addition & 0 deletions src/app/components/saved_playlists/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod saved_playlists;
mod saved_playlists_model;

Expand Down
6 changes: 6 additions & 0 deletions src/app/components/saved_playlists/saved_playlists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ glib::wrapper! {
pub struct SavedPlaylistsWidget(ObjectSubclass<imp::SavedPlaylistsWidget>) @extends gtk::Widget, gtk::Box;
}

impl Default for SavedPlaylistsWidget {
fn default() -> Self {
Self::new()
}
}

impl SavedPlaylistsWidget {
pub fn new() -> Self {
glib::Object::new()
Expand Down
1 change: 1 addition & 0 deletions src/app/components/saved_tracks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod saved_tracks;
pub use saved_tracks::*;

Expand Down
1 change: 1 addition & 0 deletions src/app/components/search/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod search;
pub use search::*;

Expand Down
6 changes: 6 additions & 0 deletions src/app/components/search/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ glib::wrapper! {
pub struct SearchResultsWidget(ObjectSubclass<imp::SearchResultsWidget>) @extends gtk::Widget, gtk::Box;
}

impl Default for SearchResultsWidget {
fn default() -> Self {
Self::new()
}
}

impl SearchResultsWidget {
pub fn new() -> Self {
glib::Object::new()
Expand Down
1 change: 1 addition & 0 deletions src/app/components/settings/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod settings;
mod settings_model;

Expand Down
6 changes: 6 additions & 0 deletions src/app/components/settings/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ glib::wrapper! {
pub struct SettingsWindow(ObjectSubclass<imp::SettingsWindow>) @extends gtk::Widget, gtk::Window, libadwaita::Window, libadwaita::PreferencesWindow;
}

impl Default for SettingsWindow {
fn default() -> Self {
Self::new()
}
}

impl SettingsWindow {
pub fn new() -> Self {
let window: Self = glib::Object::new();
Expand Down
6 changes: 6 additions & 0 deletions src/app/components/sidebar/create_playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ glib::wrapper! {
pub struct CreatePlaylistPopover(ObjectSubclass<imp::CreatePlaylistPopover>) @extends gtk::Widget, gtk::Popover;
}

impl Default for CreatePlaylistPopover {
fn default() -> Self {
Self::new()
}
}

impl CreatePlaylistPopover {
pub fn new() -> Self {
glib::Object::new()
Expand Down
1 change: 1 addition & 0 deletions src/app/components/sidebar/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod sidebar;
pub use sidebar::*;

Expand Down
10 changes: 5 additions & 5 deletions src/app/components/sidebar/sidebar_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl SidebarItem {
};
glib::Object::builder()
.property("id", id)
.property("data", &data.unwrap_or_default())
.property("data", data.unwrap_or_default())
.property("title", &title)
.property("navigatable", true)
.build()
Expand All @@ -77,17 +77,17 @@ impl SidebarItem {
pub fn playlists_section() -> Self {
glib::Object::builder()
.property("id", SAVED_PLAYLISTS_SECTION)
.property("data", &String::new())
.property("title", &gettext("All Playlists"))
.property("data", String::new())
.property("title", gettext("All Playlists"))
.property("navigatable", false)
.build()
}

pub fn create_playlist_item() -> Self {
glib::Object::builder()
.property("id", CREATE_PLAYLIST_ITEM)
.property("data", &String::new())
.property("title", &gettext("New Playlist"))
.property("data", String::new())
.property("title", gettext("New Playlist"))
.property("navigatable", false)
.build()
}
Expand Down
1 change: 1 addition & 0 deletions src/app/components/user_details/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod user_details;
pub use user_details::*;

Expand Down
1 change: 1 addition & 0 deletions src/app/components/user_menu/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(clippy::module_inception)]
mod user_menu;
pub use user_menu::*;

Expand Down
4 changes: 2 additions & 2 deletions src/app/components/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use crate::app::{AppEvent, AppModel};
use crate::settings::WindowGeometry;

thread_local! {
static WINDOW_GEOMETRY: RefCell<WindowGeometry> = RefCell::new(WindowGeometry {
static WINDOW_GEOMETRY: RefCell<WindowGeometry> = const { RefCell::new(WindowGeometry {
width: 0, height: 0, is_maximized: false
});
}) };
}

pub struct MainWindow {
Expand Down
Loading

0 comments on commit b2d77f6

Please sign in to comment.