Skip to content

Commit

Permalink
[irods#34] Wrapped single-line bodies of if statements
Browse files Browse the repository at this point in the history
in curly braces

- Only done in operation files
  • Loading branch information
farbs03 committed Aug 1, 2024
1 parent d4812ea commit 79b6b47
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 65 deletions.
46 changes: 34 additions & 12 deletions src/operations/collections/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@ export class CollectionOperations {
toURLSearchParams({ op: 'create', ...params })
)
const data: CollectionTypes.CollectionCreateResponse = res.data
if (!data.created)
if (!data.created) {
message = `Failed to create collection: '${params.lpath}' already exists`
else message = `Successfully created collection '${params.lpath}'`
} else {
message = `Successfully created collection '${params.lpath}'`
}
retData = { status: res.status, data: res.data }
} catch (error) {
assert(error instanceof AxiosError)
message = `Failed to create collection '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -53,7 +57,9 @@ export class CollectionOperations {
message = `Failed to remove collection '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -73,7 +79,9 @@ export class CollectionOperations {
message = `Failed to retrieve information for collection '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -93,7 +101,9 @@ export class CollectionOperations {
message = `Failed to retrieve list for collection '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -116,7 +126,9 @@ export class CollectionOperations {
message = `Failed to set permission for entity '${params['entity-name']}' to '${params.permission}' on collection '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand Down Expand Up @@ -145,7 +157,9 @@ export class CollectionOperations {
}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -168,7 +182,9 @@ export class CollectionOperations {
message = `Failed to modify permissions for collection '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -191,7 +207,9 @@ export class CollectionOperations {
message = `Failed to modify metadata for collection '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -212,7 +230,9 @@ export class CollectionOperations {
message = `Failed to rename collection '${params['old-lpath']}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -233,7 +253,9 @@ export class CollectionOperations {
message = `Failed to update mtime for collection '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}
}
77 changes: 57 additions & 20 deletions src/operations/data_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export class DataObjectOperations {
message = `Failed to create or update mtime of data object '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -51,7 +53,9 @@ export class DataObjectOperations {
message = `Failed to remove data object '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -74,7 +78,9 @@ export class DataObjectOperations {
message = `Failed to calculate checksum for data object '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -96,7 +102,9 @@ export class DataObjectOperations {
message = `Failed to verify checksum for data object '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -116,7 +124,9 @@ export class DataObjectOperations {
message = `Failed to retrieve information for data object '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -137,7 +147,9 @@ export class DataObjectOperations {
message = `Failed to rename data object '${params['old-lpath']}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -158,7 +170,9 @@ export class DataObjectOperations {
message = `Failed to copy data object '${params['src-lpath']}' to '${params['dst-lpath']}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -181,7 +195,9 @@ export class DataObjectOperations {
message = `Failed to replicate data object '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -202,7 +218,9 @@ export class DataObjectOperations {
message = `Failed to trim data object '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -225,7 +243,9 @@ export class DataObjectOperations {
message = `Failed to register physical object '${params.ppath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -246,7 +266,9 @@ export class DataObjectOperations {
message = `Failed to read data object '${params.lpath}'`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand Down Expand Up @@ -282,7 +304,9 @@ export class DataObjectOperations {
message = `Failed to write to data object '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -305,7 +329,9 @@ export class DataObjectOperations {
message = `Failed to initialize parallel write session for data object '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -328,7 +354,9 @@ export class DataObjectOperations {
message = `Failed to shut down parallel write session: ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -351,7 +379,9 @@ export class DataObjectOperations {
message = `Failed to modify metadata for data object '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -374,7 +404,9 @@ export class DataObjectOperations {
message = `Failed to set permission for entity '${params['entity-name']}' to '${params.permission}' on data object '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -397,7 +429,9 @@ export class DataObjectOperations {
message = `Failed to modify permissions for data object '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -414,17 +448,20 @@ export class DataObjectOperations {
toURLSearchParams({ op: 'modify_replica', ...params })
)
// If params['replica-number'] doesn't exist, then params['resource-hierarchy'] does (or should, at least)
if (params['replica-number'])
if (params['replica-number']) {
message = `Successfully modified replica number ${params['replica-number']} of data object '${params.lpath}'`
else
} else {
message = `Successfully modified replica of data object '${params.lpath}' with resource hierarchy '${params['resource-hierarchy']}'`
}
retData = { status: res.status, data: res.data }
} catch (error) {
assert(error instanceof AxiosError)
message = `Failed to modify replica of data object '${params.lpath}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}
}
16 changes: 12 additions & 4 deletions src/operations/query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export class QueryOperations {
message = `Failed to execute genquery: ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -54,7 +56,9 @@ export class QueryOperations {
message = `Failed to execute specific query '${params.name}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -78,7 +82,9 @@ export class QueryOperations {
message = `Failed to add specific query '${params.name}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}

Expand All @@ -102,7 +108,9 @@ export class QueryOperations {
message = `Failed to remove specific query '${params.name}': ${error.message}`
retData = { status: error.response?.status!, data: null }
}
if (this.debug) console.log(message)
if (this.debug) {
console.log(message)
}
return retData
}
}
Loading

0 comments on commit 79b6b47

Please sign in to comment.