alacritty/alacritty

Refactoring required

Guelakais opened this issue · 2 comments

After briefly skimming the code, I realised that it is unfortunately somewhat confusing. I would like to fix this and in order to work properly on the project, I have opened an issue first so that I can reference it later in a pull request. I would like to show you a short example:

use std::cmp::max;
use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
use std::path::PathBuf;
use std::rc::Rc;

use alacritty_config::SerdeReplace;
use clap::{ArgAction, Args, Parser, Subcommand, ValueHint};
use log::{error, LevelFilter};
use serde::{Deserialize, Serialize};
use toml::Value;

use alacritty_terminal::tty::Options as PtyOptions;

use crate::config::ui_config::Program;
use crate::config::window::{Class, Identity};
use crate::config::UiConfig;
use crate::logging::LOG_TARGET_IPC_CONFIG;

This can be written down much more neatly, which rust also allows:

use std::{cmp::max,collections::HashMap,ops::{Deref, DerefMut},path::PathBuf,rc::Rc};

use alacritty_config::SerdeReplace;
use clap::{ArgAction, Args, Parser, Subcommand, ValueHint};
use log::{error, LevelFilter};
use serde::{Deserialize, Serialize};
use toml::Value;

use alacritty_terminal::tty::Options as PtyOptions;
use crate::{config::{ui_config::Program,window::{Class, Identity},UiConfig},logging::LOG_TARGET_IPC_CONFIG};

Proper refactoring and formatting helps to clarify dependencies and can simplify further development.

This just looks unreadable.

This just looks unreadable.

Not only this, it also generates much worse diffs. There's really no good reason to use this import format.