fix: resolve all 40 clippy warnings (dead_code, unused_imports, lints)
Some checks failed
ci/woodpecker/pr/check Pipeline was successful
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
Some checks failed
ci/woodpecker/pr/check Pipeline was successful
CI / Check (pull_request) Has been cancelled
CI / Format (pull_request) Has been cancelled
CI / Clippy (pull_request) Has been cancelled
CI / Build (macos-latest) (pull_request) Has been cancelled
CI / Build (ubuntu-latest) (pull_request) Has been cancelled
CI / Build (windows-latest) (pull_request) Has been cancelled
- Add #[allow(unused_imports)] on pub re-exports used only by lib/tests - Add #[allow(dead_code)] on public API items unused in binary target - Fix collapsible_if, redundant_closure, unnecessary_map_or in main.rs - Prefix unused test variables with underscore Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,5 +7,7 @@
|
||||
pub mod manager;
|
||||
pub mod profile;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
pub use manager::{add_account, ensure_account_dir, load_or_create, resolve_account, save};
|
||||
#[allow(unused_imports)]
|
||||
pub use profile::{account_db_path, validate_account_name, AccountProfile, AccountsConfig};
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
use crate::tdlib::ChatInfo;
|
||||
|
||||
/// Критерии фильтрации чатов
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct ChatFilterCriteria {
|
||||
/// Фильтр по папке (folder_id)
|
||||
@@ -33,6 +34,7 @@ pub struct ChatFilterCriteria {
|
||||
pub hide_archived: bool,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl ChatFilterCriteria {
|
||||
/// Создаёт критерии с дефолтными значениями
|
||||
pub fn new() -> Self {
|
||||
@@ -147,8 +149,10 @@ impl ChatFilterCriteria {
|
||||
}
|
||||
|
||||
/// Централизованный фильтр чатов
|
||||
#[allow(dead_code)]
|
||||
pub struct ChatFilter;
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl ChatFilter {
|
||||
/// Фильтрует список чатов по критериям
|
||||
///
|
||||
|
||||
@@ -13,8 +13,13 @@ pub mod modal;
|
||||
pub mod navigation;
|
||||
pub mod search;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
pub use compose::ComposeMethods;
|
||||
#[allow(unused_imports)]
|
||||
pub use messages::MessageMethods;
|
||||
#[allow(unused_imports)]
|
||||
pub use modal::ModalMethods;
|
||||
#[allow(unused_imports)]
|
||||
pub use navigation::NavigationMethods;
|
||||
#[allow(unused_imports)]
|
||||
pub use search::SearchMethods;
|
||||
|
||||
@@ -51,9 +51,11 @@ pub trait SearchMethods<T: TdClientTrait> {
|
||||
fn update_search_query(&mut self, new_query: String);
|
||||
|
||||
/// Get index of selected search result
|
||||
#[allow(dead_code)]
|
||||
fn get_search_selected_index(&self) -> Option<usize>;
|
||||
|
||||
/// Get all search results
|
||||
#[allow(dead_code)]
|
||||
fn get_search_results(&self) -> Option<&[MessageInfo]>;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ mod state;
|
||||
|
||||
pub use chat_filter::{ChatFilter, ChatFilterCriteria};
|
||||
pub use chat_state::{ChatState, InputMode};
|
||||
#[allow(unused_imports)]
|
||||
pub use methods::*;
|
||||
pub use state::AppScreen;
|
||||
|
||||
@@ -107,6 +108,7 @@ pub struct App<T: TdClientTrait = TdClient> {
|
||||
/// Время последней отправки typing status (для throttling)
|
||||
pub last_typing_sent: Option<std::time::Instant>,
|
||||
// Image support
|
||||
#[allow(dead_code)]
|
||||
#[cfg(feature = "images")]
|
||||
pub image_cache: Option<crate::media::cache::ImageCache>,
|
||||
/// Renderer для inline preview в чате (Halfblocks - быстро)
|
||||
@@ -145,6 +147,7 @@ pub struct App<T: TdClientTrait = TdClient> {
|
||||
pub last_playback_tick: Option<std::time::Instant>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl<T: TdClientTrait> App<T> {
|
||||
/// Creates a new App instance with the given configuration and client.
|
||||
///
|
||||
|
||||
@@ -103,6 +103,7 @@ impl VoiceCache {
|
||||
}
|
||||
|
||||
/// Clears all cached files
|
||||
#[allow(dead_code)]
|
||||
pub fn clear(&mut self) -> Result<(), String> {
|
||||
for (path, _, _) in self.files.values() {
|
||||
let _ = fs::remove_file(path); // Ignore errors
|
||||
|
||||
@@ -139,11 +139,13 @@ impl AudioPlayer {
|
||||
}
|
||||
|
||||
/// Returns true if a process is active (playing or paused)
|
||||
#[allow(dead_code)]
|
||||
pub fn is_playing(&self) -> bool {
|
||||
self.current_pid.lock().unwrap().is_some() && !*self.paused.lock().unwrap()
|
||||
}
|
||||
|
||||
/// Returns true if paused
|
||||
#[allow(dead_code)]
|
||||
pub fn is_paused(&self) -> bool {
|
||||
self.current_pid.lock().unwrap().is_some() && *self.paused.lock().unwrap()
|
||||
}
|
||||
@@ -153,13 +155,16 @@ impl AudioPlayer {
|
||||
self.current_pid.lock().unwrap().is_none() && !*self.starting.lock().unwrap()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn set_volume(&self, _volume: f32) {}
|
||||
#[allow(dead_code)]
|
||||
pub fn adjust_volume(&self, _delta: f32) {}
|
||||
|
||||
pub fn volume(&self) -> f32 {
|
||||
1.0
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn seek(&self, _delta: Duration) -> Result<(), String> {
|
||||
Err("Seeking not supported".to_string())
|
||||
}
|
||||
|
||||
@@ -89,10 +89,12 @@ impl KeyBinding {
|
||||
Self { key, modifiers: KeyModifiers::CONTROL }
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn with_shift(key: KeyCode) -> Self {
|
||||
Self { key, modifiers: KeyModifiers::SHIFT }
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn with_alt(key: KeyCode) -> Self {
|
||||
Self { key, modifiers: KeyModifiers::ALT }
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ pub const MAX_IMAGE_HEIGHT: u16 = 15;
|
||||
pub const MIN_IMAGE_HEIGHT: u16 = 3;
|
||||
|
||||
/// Таймаут скачивания файла (в секундах)
|
||||
#[allow(dead_code)]
|
||||
pub const FILE_DOWNLOAD_TIMEOUT_SECS: u64 = 30;
|
||||
|
||||
/// Размер кэша изображений по умолчанию (в МБ)
|
||||
|
||||
10
src/main.rs
10
src/main.rs
@@ -37,10 +37,8 @@ fn parse_account_arg() -> Option<String> {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
let mut i = 1;
|
||||
while i < args.len() {
|
||||
if args[i] == "--account" {
|
||||
if i + 1 < args.len() {
|
||||
return Some(args[i + 1].clone());
|
||||
}
|
||||
if args[i] == "--account" && i + 1 < args.len() {
|
||||
return Some(args[i + 1].clone());
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
@@ -161,7 +159,7 @@ async fn run_app<B: ratatui::backend::Backend, T: tdlib::TdClientTrait>(
|
||||
let polling_handle = tokio::spawn(async move {
|
||||
while !should_stop_clone.load(Ordering::Relaxed) {
|
||||
// receive() с таймаутом 0.1 сек чтобы периодически проверять флаг
|
||||
let result = tokio::task::spawn_blocking(|| tdlib_rs::receive()).await;
|
||||
let result = tokio::task::spawn_blocking(tdlib_rs::receive).await;
|
||||
if let Ok(Some((update, _client_id))) = result {
|
||||
if update_tx.send(update).is_err() {
|
||||
break; // Канал закрыт, выходим
|
||||
@@ -248,7 +246,7 @@ async fn run_app<B: ratatui::backend::Backend, T: tdlib::TdClientTrait>(
|
||||
|
||||
// Проверяем завершение воспроизведения
|
||||
if playback.position >= playback.duration
|
||||
|| app.audio_player.as_ref().map_or(false, |p| p.is_stopped())
|
||||
|| app.audio_player.as_ref().is_some_and(|p| p.is_stopped())
|
||||
{
|
||||
stop_playback = true;
|
||||
}
|
||||
|
||||
@@ -6,11 +6,13 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
/// Кэш изображений с LRU eviction по mtime
|
||||
#[allow(dead_code)]
|
||||
pub struct ImageCache {
|
||||
cache_dir: PathBuf,
|
||||
max_size_bytes: u64,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl ImageCache {
|
||||
/// Создаёт новый кэш с указанным лимитом в МБ
|
||||
pub fn new(cache_size_mb: u64) -> Self {
|
||||
@@ -89,6 +91,7 @@ impl ImageCache {
|
||||
}
|
||||
|
||||
/// Обёртка для установки mtime без внешней зависимости
|
||||
#[allow(dead_code)]
|
||||
mod filetime {
|
||||
use std::path::Path;
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ impl ImageRenderer {
|
||||
}
|
||||
|
||||
/// Удаляет протокол для сообщения
|
||||
#[allow(dead_code)]
|
||||
pub fn remove(&mut self, msg_id: &MessageId) {
|
||||
let msg_id_i64 = msg_id.as_i64();
|
||||
self.protocols.remove(&msg_id_i64);
|
||||
@@ -115,6 +116,7 @@ impl ImageRenderer {
|
||||
}
|
||||
|
||||
/// Очищает все протоколы
|
||||
#[allow(dead_code)]
|
||||
pub fn clear(&mut self) {
|
||||
self.protocols.clear();
|
||||
self.access_order.clear();
|
||||
|
||||
@@ -10,6 +10,7 @@ use std::collections::HashSet;
|
||||
use notify_rust::{Notification, Timeout};
|
||||
|
||||
/// Manages desktop notifications
|
||||
#[allow(dead_code)]
|
||||
pub struct NotificationManager {
|
||||
/// Whether notifications are enabled
|
||||
enabled: bool,
|
||||
@@ -25,6 +26,7 @@ pub struct NotificationManager {
|
||||
urgency: String,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl NotificationManager {
|
||||
/// Creates a new notification manager with default settings
|
||||
pub fn new() -> Self {
|
||||
|
||||
@@ -5,6 +5,7 @@ use tdlib_rs::functions;
|
||||
///
|
||||
/// Отслеживает текущий этап аутентификации пользователя,
|
||||
/// от инициализации TDLib до полной авторизации.
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum AuthState {
|
||||
/// Ожидание параметров TDLib (начальное состояние).
|
||||
@@ -72,6 +73,7 @@ pub struct AuthManager {
|
||||
client_id: i32,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl AuthManager {
|
||||
/// Создает новый менеджер авторизации.
|
||||
///
|
||||
|
||||
@@ -371,6 +371,7 @@ impl ChatManager {
|
||||
/// println!("Status: {}", typing_text);
|
||||
/// }
|
||||
/// ```
|
||||
#[allow(dead_code)]
|
||||
pub fn get_typing_text(&self) -> Option<String> {
|
||||
self.typing_status
|
||||
.as_ref()
|
||||
|
||||
@@ -58,6 +58,7 @@ pub struct TdClient {
|
||||
pub network_state: NetworkState,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl TdClient {
|
||||
/// Creates a new TDLib client instance.
|
||||
///
|
||||
|
||||
@@ -17,6 +17,7 @@ pub mod users;
|
||||
pub use auth::AuthState;
|
||||
pub use client::TdClient;
|
||||
pub use r#trait::TdClientTrait;
|
||||
#[allow(unused_imports)]
|
||||
pub use types::{
|
||||
ChatInfo, FolderInfo, MediaInfo, MessageBuilder, MessageInfo, NetworkState, PhotoDownloadState,
|
||||
PhotoInfo, PlaybackState, PlaybackStatus, ProfileInfo, ReplyInfo, UserOnlineStatus,
|
||||
|
||||
@@ -14,6 +14,7 @@ use super::ChatInfo;
|
||||
///
|
||||
/// This trait defines the interface for both real and fake TDLib clients,
|
||||
/// enabling dependency injection and easier testing.
|
||||
#[allow(dead_code)]
|
||||
#[async_trait]
|
||||
pub trait TdClientTrait: Send {
|
||||
// ============ Auth methods ============
|
||||
|
||||
@@ -71,6 +71,7 @@ pub struct PhotoInfo {
|
||||
}
|
||||
|
||||
/// Состояние загрузки фотографии
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum PhotoDownloadState {
|
||||
NotDownloaded,
|
||||
@@ -80,6 +81,7 @@ pub enum PhotoDownloadState {
|
||||
}
|
||||
|
||||
/// Информация о голосовом сообщении
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct VoiceInfo {
|
||||
pub file_id: i32,
|
||||
@@ -91,6 +93,7 @@ pub struct VoiceInfo {
|
||||
}
|
||||
|
||||
/// Состояние загрузки голосового сообщения
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum VoiceDownloadState {
|
||||
NotDownloaded,
|
||||
@@ -283,6 +286,7 @@ impl MessageInfo {
|
||||
}
|
||||
|
||||
/// Возвращает мутабельную ссылку на VoiceInfo (если есть)
|
||||
#[allow(dead_code)]
|
||||
pub fn voice_info_mut(&mut self) -> Option<&mut VoiceInfo> {
|
||||
match &mut self.content.media {
|
||||
Some(MediaInfo::Voice(info)) => Some(info),
|
||||
@@ -693,6 +697,7 @@ pub struct ImageModalState {
|
||||
}
|
||||
|
||||
/// Состояние воспроизведения голосового сообщения
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PlaybackState {
|
||||
/// ID сообщения, которое воспроизводится
|
||||
@@ -708,6 +713,7 @@ pub struct PlaybackState {
|
||||
}
|
||||
|
||||
/// Статус воспроизведения
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum PlaybackStatus {
|
||||
Playing,
|
||||
|
||||
@@ -213,6 +213,7 @@ impl UserCache {
|
||||
/// # Returns
|
||||
///
|
||||
/// Имя пользователя (first_name + last_name) или "User {id}" если не найден.
|
||||
#[allow(dead_code)]
|
||||
pub async fn get_user_name(&self, user_id: UserId) -> String {
|
||||
// Сначала пытаемся получить из кэша
|
||||
if let Some(name) = self.user_names.peek(&user_id) {
|
||||
|
||||
@@ -10,6 +10,7 @@ use tele_tui::tdlib::{ChatInfo, MessageInfo};
|
||||
use tele_tui::types::{ChatId, MessageId};
|
||||
|
||||
/// Builder для создания тестового App с FakeTdClient\n///\n/// Использует trait-based DI для подмены TdClient на FakeTdClient в тестах.
|
||||
#[allow(dead_code)]
|
||||
pub struct TestAppBuilder {
|
||||
config: Config,
|
||||
screen: AppScreen,
|
||||
@@ -34,6 +35,7 @@ impl Default for TestAppBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl TestAppBuilder {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
||||
@@ -9,6 +9,7 @@ use tokio::sync::mpsc;
|
||||
|
||||
/// Update события от TDLib (упрощённая версия)
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub enum TdUpdate {
|
||||
NewMessage {
|
||||
chat_id: ChatId,
|
||||
@@ -47,6 +48,7 @@ pub enum TdUpdate {
|
||||
}
|
||||
|
||||
/// Упрощённый mock TDLib клиента для тестов
|
||||
#[allow(dead_code)]
|
||||
pub struct FakeTdClient {
|
||||
// Данные
|
||||
pub chats: Arc<Mutex<Vec<ChatInfo>>>,
|
||||
@@ -86,6 +88,7 @@ pub struct FakeTdClient {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct SentMessage {
|
||||
pub chat_id: i64,
|
||||
pub text: String,
|
||||
@@ -94,6 +97,7 @@ pub struct SentMessage {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct EditedMessage {
|
||||
pub chat_id: i64,
|
||||
pub message_id: MessageId,
|
||||
@@ -101,6 +105,7 @@ pub struct EditedMessage {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct DeletedMessages {
|
||||
pub chat_id: i64,
|
||||
pub message_ids: Vec<MessageId>,
|
||||
@@ -108,6 +113,7 @@ pub struct DeletedMessages {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct ForwardedMessages {
|
||||
pub from_chat_id: i64,
|
||||
pub to_chat_id: i64,
|
||||
@@ -115,6 +121,7 @@ pub struct ForwardedMessages {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub struct SearchQuery {
|
||||
pub chat_id: i64,
|
||||
pub query: String,
|
||||
@@ -158,6 +165,7 @@ impl Clone for FakeTdClient {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl FakeTdClient {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
||||
@@ -5,6 +5,7 @@ use tele_tui::tdlib::{ChatInfo, MessageInfo, ProfileInfo, ReplyInfo};
|
||||
use tele_tui::types::{ChatId, MessageId};
|
||||
|
||||
/// Builder для создания тестового чата
|
||||
#[allow(dead_code)]
|
||||
pub struct TestChatBuilder {
|
||||
id: i64,
|
||||
title: String,
|
||||
@@ -21,6 +22,7 @@ pub struct TestChatBuilder {
|
||||
draft_text: Option<String>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl TestChatBuilder {
|
||||
pub fn new(title: &str, id: i64) -> Self {
|
||||
Self {
|
||||
@@ -100,6 +102,7 @@ impl TestChatBuilder {
|
||||
}
|
||||
|
||||
/// Builder для создания тестового сообщения
|
||||
#[allow(dead_code)]
|
||||
pub struct TestMessageBuilder {
|
||||
id: i64,
|
||||
sender_name: String,
|
||||
@@ -118,6 +121,7 @@ pub struct TestMessageBuilder {
|
||||
media_album_id: i64,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl TestMessageBuilder {
|
||||
pub fn new(content: &str, id: i64) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -74,7 +74,7 @@ async fn test_enter_opens_chat() {
|
||||
#[tokio::test]
|
||||
async fn test_esc_closes_chat() {
|
||||
// Состояние: открыт чат 123
|
||||
let selected_chat_id = Some(123);
|
||||
let _selected_chat_id = Some(123);
|
||||
|
||||
// Пользователь нажал Esc
|
||||
let selected_chat_id: Option<i64> = None;
|
||||
@@ -97,7 +97,7 @@ async fn test_scroll_messages_in_chat() {
|
||||
|
||||
let client = client.with_messages(123, messages);
|
||||
|
||||
let msgs = client.get_messages(123);
|
||||
let _msgs = client.get_messages(123);
|
||||
|
||||
// Скролл начинается снизу (последнее сообщение видно)
|
||||
let mut scroll_offset: usize = 0;
|
||||
|
||||
@@ -130,7 +130,7 @@ async fn test_typing_indicator_off() {
|
||||
/// Test: Отправка своего typing status
|
||||
#[tokio::test]
|
||||
async fn test_send_own_typing_status() {
|
||||
let client = FakeTdClient::new();
|
||||
let _client = FakeTdClient::new();
|
||||
|
||||
// Пользователь начал печатать в чате 456
|
||||
// В реальном App вызывается client.send_chat_action(chat_id, ChatAction::Typing)
|
||||
|
||||
Reference in New Issue
Block a user