Skip to content

Commit 1ce3115

Browse files
authored
Fix code style and anti patterns reported by DeepSource (#118)
Fixes #109 Fixes #108
1 parent 691ebbd commit 1ce3115

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

server/build.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ mod ui {
3636
use static_files::resource_dir;
3737
use ureq::get as get_from_url;
3838

39+
const CARGO_MANIFEST_DIR: &str = "CARGO_MANIFEST_DIR";
40+
const OUT_DIR: &str = "OUT_DIR";
41+
const LOCAL_ASSETS_PATH: &str = "LOCAL_ASSETS_PATH";
42+
3943
fn build_resource_from(local_path: impl AsRef<Path>) -> io::Result<()> {
4044
let local_path = local_path.as_ref();
4145
if local_path.exists() {
@@ -49,9 +53,9 @@ mod ui {
4953
}
5054

5155
pub fn setup() -> io::Result<()> {
52-
let cargo_manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
56+
let cargo_manifest_dir = PathBuf::from(env::var(CARGO_MANIFEST_DIR).unwrap());
5357
let cargo_toml = cargo_manifest_dir.join("Cargo.toml");
54-
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
58+
let out_dir = PathBuf::from(env::var(OUT_DIR).unwrap());
5559
let parseable_ui_path = out_dir.join("ui");
5660
let checksum_path = out_dir.join("parseable_ui.sha1");
5761

@@ -69,7 +73,7 @@ mod ui {
6973

7074
// try fetching frontend path from env var
7175
let local_assets_path: Option<PathBuf> =
72-
env::var("LOCAL_ASSETS_PATH").ok().map(PathBuf::from);
76+
env::var(LOCAL_ASSETS_PATH).ok().map(PathBuf::from);
7377

7478
// If local build of ui is to be used
7579
if let Some(ref path) = local_assets_path {

server/src/handlers/logstream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub async fn put(req: HttpRequest) -> HttpResponse {
173173
// Proceed to create log stream if it doesn't exist
174174
if s3.get_schema(&stream_name).await.is_err() {
175175
if let Err(e) =
176-
metadata::STREAM_INFO.add_stream(stream_name.to_string(), None, Default::default())
176+
metadata::STREAM_INFO.add_stream(stream_name.to_string(), None, Alerts::default())
177177
{
178178
return response::ServerResponse {
179179
msg: format!(

server/src/metadata.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,13 @@ impl STREAM_INFO {
129129
alerts,
130130
..Default::default()
131131
};
132-
// TODO: Add check to confirm data insertion
133132
map.insert(stream_name, metadata);
134133

135134
Ok(())
136135
}
137136

138137
pub fn delete_stream(&self, stream_name: &str) -> Result<(), Error> {
139138
let mut map = self.write().unwrap();
140-
// TODO: Add check to confirm data deletion
141139
map.remove(stream_name);
142140

143141
Ok(())
@@ -147,8 +145,6 @@ impl STREAM_INFO {
147145
for stream in storage.list_streams().await? {
148146
// Ignore S3 errors here, because we are just trying
149147
// to load the stream metadata based on whatever is available.
150-
//
151-
// TODO: ignore failure(s) if any and skip to next stream
152148
let alerts = storage
153149
.get_alerts(&stream.name)
154150
.await

server/src/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl Query {
6969
}
7070

7171
/// Execute query on object storage(and if necessary on cache as well) with given stream information
72-
/// TODO: find a way to query all selected parquet files together in a single context.
72+
/// TODO: Query local and remote S3 parquet files in a single context
7373
pub async fn execute(&self, storage: &impl ObjectStorage) -> Result<Vec<RecordBatch>, Error> {
7474
let mut results = vec![];
7575
storage.query(self, &mut results).await?;

server/src/s3.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ impl S3 {
276276

277277
#[allow(dead_code)]
278278
async fn prefix_exists(&self, prefix: &str) -> Result<bool, AwsSdkError> {
279-
// TODO check if head object is faster compared to
280-
// list objects
279+
// TODO check if head object is faster compared to list objects
281280
let resp = self
282281
.client
283282
.list_objects_v2()

server/src/validator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::metadata::STREAM_INFO;
2626
use crate::query::Query;
2727
use crate::Error;
2828

29-
// TODO: add more sql keywords here in lower case
29+
// Add more sql keywords here in lower case
3030
const DENIED_NAMES: &[&str] = &[
3131
"select", "from", "where", "group", "by", "order", "limit", "offset", "join", "and",
3232
];

0 commit comments

Comments
 (0)