refactor: cleanup unused code and warnings
Some checks failed
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

Comprehensive cleanup of unused methods, dead code, and compiler warnings:

## Removed Methods (15):
- Duplicate delegation methods: is_authenticated, get_typing_text, get_user_name from TdClient
- Obsolete methods: TdClient::init() (duplicated in main.rs)
- Unused getters: UserCache::{get_username, get_name, get_user_id_by_chat}
- Unused builder methods: MessageBuilder::{edited, add_reaction}
- Unused utility: ChatState::is_normal()
- Dead code: HotkeysConfig::{matches, key_matches} (kept for tests)
- Unused method: UserCache::register_private_chat()
- Getter replaced with direct field access: MessageInfo::edit_date()

## Removed Module:
- error.rs - Unused error handling module (TeletuiError, ErrorVariant, IntoTeletuiError)

## Removed Constants (8):
- EMOJI_PICKER_COLUMNS, EMOJI_PICKER_ROWS, MAX_INPUT_HEIGHT
- MIN_TERMINAL_WIDTH, MIN_TERMINAL_HEIGHT
- TDLIB_CHAT_LIMIT, MAX_USERNAME_DISPLAY_LENGTH, MESSAGE_TEXT_INDENT

## Fixed Warnings:
- Removed unused imports (8 instances)
- Fixed unreachable patterns (10 instances)
- Fixed irrefutable if let patterns (2 instances)
- Fixed unused variables (1 instance)
- Removed dead_code annotations where appropriate

## Improvements:
- Integrated Config::load_credentials() into TdClient::new() for better credential management
- Replaced edit_date() getter with direct field access (message.metadata.edit_date)
- Updated tests to use direct field access instead of removed getters

## Test Results:
All tests passing: 499 passed, 0 failed

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Mikhail Kilin
2026-02-01 18:57:55 +03:00
parent f1a26b906c
commit 2b04b785c0
20 changed files with 57 additions and 292 deletions

View File

@@ -160,10 +160,6 @@ impl MessageInfo {
self.metadata.date
}
pub fn edit_date(&self) -> i32 {
self.metadata.edit_date
}
pub fn is_edited(&self) -> bool {
self.metadata.edit_date > 0
}
@@ -308,12 +304,6 @@ impl MessageBuilder {
self
}
/// Пометить сообщение как отредактированное (edit_date = date + 60)
pub fn edited(mut self) -> Self {
self.edit_date = self.date + 60;
self
}
/// Пометить сообщение как прочитанное
pub fn read(mut self) -> Self {
self.is_read = true;
@@ -362,12 +352,6 @@ impl MessageBuilder {
self
}
/// Добавить одну реакцию
pub fn add_reaction(mut self, reaction: ReactionInfo) -> Self {
self.reactions.push(reaction);
self
}
/// Построить MessageInfo из данных builder'а
pub fn build(self) -> MessageInfo {
MessageInfo::new(
@@ -430,11 +414,11 @@ mod tests {
let message = MessageBuilder::new(MessageId::new(789))
.text("Original text")
.date(1640000000)
.edited()
.edit_date(1640000060)
.build();
assert!(message.is_edited());
assert_eq!(message.edit_date(), 1640000060);
assert_eq!(message.metadata.edit_date, 1640000060);
}
#[test]
@@ -464,7 +448,7 @@ mod tests {
let message = MessageBuilder::new(MessageId::new(300))
.text("Cool message")
.add_reaction(reaction.clone())
.reactions(vec![reaction.clone()])
.build();
assert_eq!(message.reactions().len(), 1);