lint(curly): consistent use of curly brackets in codebase (#3584)

This commit is contained in:
Alireza authored and GitHub committed 2023-08-09 10:07:33 -04:00
1 parent 9ae3d9f769
commit 5d435424e2
113 files changed
+1501 -1056

No files matched your search

@@ -46,7 +46,9 @@ function createDicomJSONApi(dicomJsonConfig) {
const implementation = {
initialize: async ({ query, url }) => {
if (!url) url = query.get('url');
if (!url) {
url = query.get('url');
}
let metaData = getMetaDataByURL(url);
// if we have already cached the data from this specific url
@@ -212,7 +214,9 @@ function createDicomJSONApi(dicomJsonConfig) {
return obj;
});
storeInstances(instances);
if (index === numberOfSeries - 1) setSuccessFlag();
if (index === numberOfSeries - 1) {
setSuccessFlag();
}
});
},
},
@@ -12,8 +12,12 @@ const END_MODALITIES = {
};
const compareValue = (v1, v2, def = 0) => {
if (v1 === v2) return def;
if (v1 < v2) return -1;
if (v1 === v2) {
return def;
}
if (v1 < v2) {
return -1;
}
return 1;
};
@@ -1,4 +1,4 @@
export default function (wadoRoot) {
export default function(wadoRoot) {
return {
series: (StudyInstanceUID, SeriesInstanceUID) => {
return new Promise((resolve, reject) => {
@@ -15,7 +15,7 @@ export default function (wadoRoot) {
console.log(xhr);
xhr.onreadystatechange = function () {
xhr.onreadystatechange = function() {
//Call a function when the state changes.
if (xhr.readyState == 4) {
switch (xhr.status) {
@@ -36,12 +36,16 @@ export default class StaticWadoClient extends api.DICOMwebClient {
* @returns
*/
async searchForStudies(options) {
if (!this.staticWado) return super.searchForStudies(options);
if (!this.staticWado) {
return super.searchForStudies(options);
}
const searchResult = await super.searchForStudies(options);
const { queryParams } = options;
if (!queryParams) return searchResult;
if (!queryParams) {
return searchResult;
}
const lowerParams = this.toLowerParams(queryParams);
const filtered = searchResult.filter(study => {
@@ -63,11 +67,15 @@ export default class StaticWadoClient extends api.DICOMwebClient {
}
async searchForSeries(options) {
if (!this.staticWado) return super.searchForSeries(options);
if (!this.staticWado) {
return super.searchForSeries(options);
}
const searchResult = await super.searchForSeries(options);
const { queryParams } = options;
if (!queryParams) return searchResult;
if (!queryParams) {
return searchResult;
}
const lowerParams = this.toLowerParams(queryParams);
const filtered = searchResult.filter(series => {
@@ -112,8 +120,12 @@ export default class StaticWadoClient extends api.DICOMwebClient {
actual = actual.Alphabetic;
}
if (typeof actual == 'string') {
if (actual.length === 0) return true;
if (desired.length === 0 || desired === '*') return true;
if (actual.length === 0) {
return true;
}
if (desired.length === 0 || desired === '*') {
return true;
}
if (desired[0] === '*' && desired[desired.length - 1] === '*') {
// console.log(`Comparing ${actual} to ${desired.substring(1, desired.length - 1)}`)
return actual.indexOf(desired.substring(1, desired.length - 1)) != -1;
@@ -131,9 +143,13 @@ export default class StaticWadoClient extends api.DICOMwebClient {
/** Compares a pair of dates to see if the value is within the range */
compareDateRange(range, value) {
if (!value) return true;
if (!value) {
return true;
}
const dash = range.indexOf('-');
if (dash === -1) return this.compareValues(range, value);
if (dash === -1) {
return this.compareValues(range, value);
}
const start = range.substring(0, dash);
const end = range.substring(dash + 1);
return (!start || value >= start) && (!end || value <= end);
@@ -150,11 +166,17 @@ export default class StaticWadoClient extends api.DICOMwebClient {
*/
filterItem(key: string, queryParams, study, sourceFilterMap) {
const altKey = sourceFilterMap[key] || key;
if (!queryParams) return true;
if (!queryParams) {
return true;
}
const testValue = queryParams[key] || queryParams[altKey];
if (!testValue) return true;
if (!testValue) {
return true;
}
const valueElem = study[key] || study[altKey];
if (!valueElem) return false;
if (!valueElem) {
return false;
}
if (valueElem.vr == 'DA') {
return this.compareDateRange(testValue, valueElem.Value[0]);
}
@@ -276,7 +276,9 @@ function _mapMeasurementToDisplay(measurement, index, types) {
if (findingSites) {
const siteText = [];
findingSites.forEach(site => {
if (site?.text !== label) siteText.push(site.text);
if (site?.text !== label) {
siteText.push(site.text);
}
});
displayText = [...siteText, ...displayText];
}
+6 -2
View File
@@ -9,12 +9,16 @@ function debounce(func, wait, immediate) {
args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
if (!immediate) {
func.apply(context, args);
}
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
if (callNow) {
func.apply(context, args);
}
};
}
@@ -40,8 +40,8 @@ NestedMenu.propTypes = {
};
NestedMenu.defaultProps = {
icon: "tool-more-menu",
label: "More",
icon: 'tool-more-menu',
label: 'More',
};
export default NestedMenu;
@@ -50,7 +50,7 @@ function ViewerLayout({
// dataSourceIdx === -1
// ? undefined
// : `datasources=${pathname.substring(dataSourceIdx + 1)}`;
// Todo: Handle parameters in a better way.
const query = new URLSearchParams(window.location.search);
const configUrl = query.get('configUrl');
@@ -69,7 +69,7 @@ function ViewerLayout({
navigate({
pathname: '/',
search: decodeURIComponent(searchQuery.toString())
search: decodeURIComponent(searchQuery.toString()),
});
};
+6 -2
View File
@@ -129,13 +129,17 @@ const commandsModule = ({
stage,
} = hangingProtocolService.getActiveProtocol();
const enableListener = button => {
if (!button.id) return;
if (!button.id) {
return;
}
const { commands, items } = button.props || button;
if (items) {
items.forEach(enableListener);
}
const hpCommand = commands?.find?.(isHangingProtocolCommand);
if (!hpCommand) return;
if (!hpCommand) {
return;
}
const { protocolId, stageIndex, stageId } = hpCommand.commandOptions;
const isActive =
(!protocolId || protocolId === protocol.id) &&
@@ -22,7 +22,9 @@ export const findOrCreateViewport = (
options: Record<string, unknown>
) => {
const byPositionViewport = viewportsByPosition?.[positionId];
if (byPositionViewport) return { ...byPositionViewport };
if (byPositionViewport) {
return { ...byPositionViewport };
}
const { protocolId, stageIndex } = hangingProtocolService.getState();
// Setup the initial in display correctly for initial view/select
@@ -83,17 +83,21 @@ export default function getCustomizationModule() {
*/
{
id: 'ohif.overlayItem',
content: function (props) {
if (this.condition && !this.condition(props)) return null;
content: function(props) {
if (this.condition && !this.condition(props)) {
return null;
}
const { instance } = props;
const value =
instance && this.attribute
? instance[this.attribute]
: this.contentF && typeof this.contentF === 'function'
? this.contentF(props)
: null;
if (!value) return null;
? this.contentF(props)
: null;
if (!value) {
return null;
}
return (
<span
@@ -117,7 +121,7 @@ export default function getCustomizationModule() {
* This function clones the object and child objects to prevent
* changes to the original customization object.
*/
transform: function (customizationService: CustomizationService) {
transform: function(customizationService: CustomizationService) {
// Don't modify the children, as those are copied by reference
const clonedObject = { ...this };
clonedObject.menus = this.menus.map(menu => ({ ...menu }));
+6 -2
View File
@@ -23,9 +23,13 @@ const getDirectURL = (config, params) => {
singlepart: fetchPart = 'video',
} = params;
const value = instance[tag];
if (!value) return undefined;
if (!value) {
return undefined;
}
if (value.DirectRetrieveURL) return value.DirectRetrieveURL;
if (value.DirectRetrieveURL) {
return value.DirectRetrieveURL;
}
if (value.InlineBinary) {
const blob = utils.b64toBlob(value.InlineBinary, defaultType);
value.DirectRetrieveURL = URL.createObjectURL(blob);
@@ -47,10 +47,14 @@ const reuseCachedLayout = (
for (let idx = 0; idx < state.viewports.length; idx++) {
const viewport = state.viewports[idx];
const { displaySetOptions, displaySetInstanceUIDs } = viewport;
if (!displaySetOptions) continue;
if (!displaySetOptions) {
continue;
}
for (let i = 0; i < displaySetOptions.length; i++) {
const displaySetUID = displaySetInstanceUIDs[i];
if (!displaySetUID) continue;
if (!displaySetUID) {
continue;
}
if (idx === activeViewportIndex && i === 0) {
displaySetSelectorMap[
`${activeStudyUID}:activeDisplaySet:0`