Skip to content

Commit

Permalink
fix: clippy lints
Browse files Browse the repository at this point in the history
Signed-off-by: simonsan <14062932+simonsan@users.noreply.github.com>
  • Loading branch information
simonsan committed Mar 19, 2024
1 parent 1e4e0b0 commit 9b2ee69
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
30 changes: 15 additions & 15 deletions crates/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,39 +111,39 @@ pub enum PaceErrorKind {
#[error(transparent)]
StdIo(#[from] std::io::Error),

/// Serialization to TOML failed: {0}
/// Serialization to TOML failed: `{0}`
#[error(transparent)]
SerializationToTomlFailed(#[from] toml::ser::Error),

/// Deserialization from TOML failed: {0}
/// Deserialization from TOML failed: `{0}`
#[error(transparent)]
DeserializationFromTomlFailed(#[from] toml::de::Error),

/// Activity store error: {0}
/// Activity store error: `{0}`
#[error(transparent)]
ActivityStore(#[from] ActivityStoreErrorKind),

/// Activity log error: {0}
/// Activity log error: `{0}`
#[error(transparent)]
ActivityLog(#[from] ActivityLogErrorKind),

/// Time related error: {0}
/// Time related error: `{0}`
#[error(transparent)]
PaceTime(#[from] PaceTimeErrorKind),

/// JSON error: {0}
/// JSON error: `{0}`
#[error(transparent)]
Json(#[from] serde_json::Error),

// /// SQLite error: {0}
// #[error(transparent)]
// #[cfg(feature = "sqlite")]
// SQLite(#[from] diesel::ConnectionError),
/// Chrono parse error: {0}
/// Chrono parse error: `{0}`
#[error(transparent)]
ChronoParse(#[from] chrono::ParseError),

/// Time chosen is not valid, because it lays before the current activity's beginning: {0}
/// Time chosen is not valid, because it lays before the current activity's beginning: `{0}`
#[error(transparent)]
ChronoDurationIsNegative(#[from] chrono::OutOfRangeError),

Expand Down Expand Up @@ -194,22 +194,22 @@ pub enum ActivityLogErrorKind {
/// Cache not available
CacheNotAvailable,

/// Activity with id '{0}' not found
/// `Activity` with id '{0}' not found
ActivityNotFound(ActivityGuid),

/// Activity with id '{0}' can't be removed from the activity log
/// `Activity` with id '{0}' can't be removed from the activity log
ActivityCantBeRemoved(usize),

/// This activity has no id
ActivityIdNotSet,

/// Activity with id '{0}' already in use, can't create a new activity with the same id
/// `Activity` with id '{0}' already in use, can't create a new activity with the same id
ActivityIdAlreadyInUse(ActivityGuid),

/// Activity in the ActivityLog has a different id than the one provided: {0} != {1}
/// `Activity` in the `ActivityLog` has a different id than the one provided: {0} != {1}
ActivityIdMismatch(ActivityGuid, ActivityGuid),

/// Activity already has an intermission: {0}
/// `Activity` already has an intermission: {0}
ActivityAlreadyHasIntermission(Box<Activity>),

/// There have been some activities that have not been ended
Expand All @@ -218,7 +218,7 @@ pub enum ActivityLogErrorKind {
/// No active activity found with id '{0}'
NoActiveActivityFound(ActivityGuid),

/// Activity with id '{0}' already ended
/// `Activity` with id '{0}' already ended
ActivityAlreadyEnded(ActivityGuid),

/// Activity with id '{0}' already has been archived
Expand All @@ -233,7 +233,7 @@ pub enum ActivityLogErrorKind {
/// No activity kind options found for activity with id '{0}'
ActivityKindOptionsNotFound(ActivityGuid),

/// ParentId not set for activity with id '{0}'
/// `ParentId` not set for activity with id '{0}'
ParentIdNotSet(ActivityGuid),

/// Category not set for activity with id '{0}'
Expand Down
6 changes: 3 additions & 3 deletions crates/core/src/storage/file.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
collections::BTreeMap,
fs::{self, OpenOptions},
fs::{create_dir_all, write, OpenOptions},
io::Write,
path::{Path, PathBuf},
};
Expand Down Expand Up @@ -99,7 +99,7 @@ impl TomlActivityStorage {
#[tracing::instrument(skip(self))]
pub fn sync_to_file(&self) -> PaceResult<()> {
let data = toml::to_string(&self.cache.get_activity_log())?;
std::fs::write(&self.path, data)?;
write(&self.path, data)?;
Ok(())
}
}
Expand All @@ -108,7 +108,7 @@ impl ActivityStorage for TomlActivityStorage {
#[tracing::instrument(skip(self))]
fn setup_storage(&self) -> PaceResult<()> {
if !self.path.exists() {
fs::create_dir_all(
create_dir_all(
self.path
.parent()
.ok_or(PaceErrorKind::ParentDirNotFound(self.path.clone()))?,
Expand Down

0 comments on commit 9b2ee69

Please sign in to comment.