nanu-c / crayfish

Other
2 stars 5 forks source link

Address cargo warnings #19

Open olof-nord opened 2 years ago

olof-nord commented 2 years ago

During build, there are a few cargo warnings about unused variables, functions and fields.

I suggest to either address the warnings by either deleting unused code, or by adding linter excludes.

  crayfish git:(main) cargo build
   Compiling crayfish v0.2.0 (/home/olof/git/crayfish)
warning: unused variable: `config`
  --> src/signal_service/sealedsender.rs:79:23
   |
79 | async fn open_storage(config: &crate::config::SignalConfig) -> anyhow::Result<Storage> {
   |                       ^^^^^^ help: if this is intentional, prefix it with an underscore: `_config`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `keys`
   --> src/store/mod.rs:152:19
    |
152 | fn load_file_sync(keys: Option<[u8; 16 + 20]>, path: PathBuf) -> Result<Vec<u8>, anyhow::Error> {
    |                   ^^^^ help: if this is intentional, prefix it with an underscore: `_keys`

warning: associated function `read_from_file` is never used
  --> src/config/signalconfig.rs:44:12
   |
44 |     pub fn read_from_file() -> Result<Self, anyhow::Error> {
   |            ^^^^^^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: associated function `write_to_file` is never used
  --> src/config/signalconfig.rs:58:12
   |
58 |     pub fn write_to_file(&self) -> Result<(), anyhow::Error> {
   |            ^^^^^^^^^^^^^

warning: associated function `get_share_dir` is never used
  --> src/config/signalconfig.rs:81:12
   |
81 |     pub fn get_share_dir(&self) -> std::path::PathBuf {
   |            ^^^^^^^^^^^^^

warning: associated function `get_storage_dir` is never used
  --> src/config/signalconfig.rs:86:12
   |
86 |     pub fn get_storage_dir(&self) -> std::path::PathBuf {
   |            ^^^^^^^^^^^^^^^

warning: associated function `default_attachment_dir` is never used
  --> src/config/signalconfig.rs:90:12
   |
90 |     pub fn default_attachment_dir(&self) -> std::path::PathBuf {
   |            ^^^^^^^^^^^^^^^^^^^^^^

warning: associated function `get_identity_dir` is never used
  --> src/config/signalconfig.rs:94:12
   |
94 |     pub fn get_identity_dir(&self) -> std::path::PathBuf {
   |            ^^^^^^^^^^^^^^^^

warning: associated function `get_tel_clone` is never used
   --> src/config/signalconfig.rs:101:12
    |
101 |     pub fn get_tel_clone(&self) -> String {
    |            ^^^^^^^^^^^^^

warning: associated function `get_uuid_clone` is never used
   --> src/config/signalconfig.rs:105:12
    |
105 |     pub fn get_uuid_clone(&self) -> String {
    |            ^^^^^^^^^^^^^^

warning: associated function `set_tel` is never used
   --> src/config/signalconfig.rs:109:12
    |
109 |     pub fn set_tel(&self, tel: String) {
    |            ^^^^^^^

warning: associated function `set_uuid` is never used
   --> src/config/signalconfig.rs:113:12
    |
113 |     pub fn set_uuid(&self, uuid: String) {
    |            ^^^^^^^^

warning: field `credential_cache` is never read
  --> src/store/mod.rs:19:5
   |
15 | pub struct Storage {
   |            ------- field in this struct
...
19 |     credential_cache: Arc<Mutex<InMemoryCredentialsCache>>,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `Storage` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis

warning: associated function `path` is never used
  --> src/store/mod.rs:24:12
   |
24 |     pub fn path(&self) -> &Path {
   |            ^^^^

warning: associated function `signal_password` is never used
  --> src/store/mod.rs:60:18
   |
60 |     pub async fn signal_password(&self) -> Result<String, anyhow::Error> {
   |                  ^^^^^^^^^^^^^^^

warning: function `load_file_sync_encrypted` is never used
   --> src/store/mod.rs:113:4
    |
113 | fn load_file_sync_encrypted(keys: [u8; 16 + 20], path: PathBuf) -> Result<Vec<u8>, anyhow::Error> {
    |    ^^^^^^^^^^^^^^^^^^^^^^^^

warning: associated function `store_with_key` is never used
  --> src/store/protocol_store.rs:30:18
   |
30 |     pub async fn store_with_key(
   |                  ^^^^^^^^^^^^^^

warning: associated function `next_pre_key_ids` is never used
   --> src/store/protocol_store.rs:100:18
    |
100 |     pub async fn next_pre_key_ids(&self) -> (u32, u32) {
    |                  ^^^^^^^^^^^^^^^^

warning: associated function `delete_identity` is never used
   --> src/store/protocol_store.rs:160:18
    |
160 |     pub async fn delete_identity(&self, addr: &ProtocolAddress) -> Result<(), SignalProtocolError> {
    |                  ^^^^^^^^^^^^^^^

warning: `crayfish` (bin "crayfish") generated 19 warnings
jonnius commented 2 years ago

I'd suggest to add a CI job running cargo clippy -- -D warnings after this is solved to avoid degrading over time. Linter warnings uncover even bugs sometimes.