Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 52dd34e

Browse files
committed
code smells
1 parent f17d4e3 commit 52dd34e

File tree

15 files changed

+49
-31
lines changed

15 files changed

+49
-31
lines changed

src/DatabaseView.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ export class DatabaseView extends TextFileView implements HoverParent {
6464
if (file) {
6565
this.file = file;
6666
this.plugin.removeView(this);
67-
this.plugin.addView(this, this.data);
67+
this.plugin.addView(this);
6868
} else {
6969
this.register(
7070
this.containerEl.onWindowMigrated(() => {
7171
this.plugin.removeView(this);
72-
this.plugin.addView(this, this.data);
72+
this.plugin.addView(this);
7373
})
7474
);
7575
}
@@ -93,7 +93,7 @@ export class DatabaseView extends TextFileView implements HoverParent {
9393
return;
9494
}
9595

96-
this.plugin.addView(this, data);
96+
this.plugin.addView(this);
9797
}
9898

9999
getIcon() {

src/commands/addDatabaseHelper/databaseHelperCreationModal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class DatabaseHelperCreationModalManager {
6262
});
6363
});
6464
const sourceOptions: Record<string, string> = {};
65-
Object.entries(SourceDataTypes).forEach(([key, value]) => {
65+
Object.entries(SourceDataTypes).forEach(([, value]) => {
6666
sourceOptions[value] = t(value);
6767
});
6868

@@ -149,7 +149,7 @@ export class DatabaseHelperCreationModalManager {
149149
}
150150

151151
tagHandler(containerEl: HTMLElement) {
152-
const tagArray: Record<string, number> = (app.metadataCache as unknown as any).getTags();
152+
const tagArray: Record<string, number> = app.metadataCache.getTags();
153153
if (tagArray) {
154154
const tagRecords: Record<string, string> = {};
155155
// Order tagRecord by key (tag name)

src/components/cellTypes/Editor/filepicker.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,14 @@ async function getBlocks(
310310
}
311311

312312
try {
313+
const cachedMetadata = app.metadataCache.getFileCache(file);
314+
313315
const blockCache = await (app.metadataCache as any).blockCache.getForFile(
314316
new MockRunnable(),
315317
file
316318
);
317319

318-
if (!blockCache?.blocks) {
320+
if (!cachedMetadata?.blocks) {
319321
return callback([]);
320322
}
321323

src/components/styles/RowTemplateStyles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { StyleVariables } from "helpers/Constants";
22
import { GroupBase, StylesConfig } from "react-select";
33

4-
const CustomTemplateSelectorStyles: StylesConfig<any, true, GroupBase<any>> = {
4+
const CustomTemplateSelectorStyles: StylesConfig<any, true, GroupBase<unknown>> = {
55
singleValue: (styles) => ({
66
...styles,
77
color: StyleVariables.TEXT_NORMAL,
@@ -10,7 +10,7 @@ const CustomTemplateSelectorStyles: StylesConfig<any, true, GroupBase<any>> = {
1010
border: 0
1111
}),
1212

13-
option: (styles, { data, isDisabled, isFocused, isSelected }) => {
13+
option: (styles) => {
1414
return {
1515
...styles,
1616
color: StyleVariables.TEXT_NORMAL,

src/components/styles/TagsStyles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
GroupBase,
66
} from "react-select";
77

8-
const CustomTagsStyles: StylesConfig<any, true, GroupBase<any>> = {
8+
const CustomTagsStyles: StylesConfig<any, true, GroupBase<unknown>> = {
99
container: () => ({
1010
position: "static",
1111
boxSizing: "border-box",

src/main.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ export default class DBFolderPlugin extends Plugin {
7474
await this.loadServices();
7575
addIcon(DB_ICONS.NAME, DB_ICONS.ICON);
7676
this.registerEvent(
77-
app.workspace.on('window-open', (_: any, win: Window) => {
77+
app.workspace.on('window-open', (_: unknown, win: Window) => {
7878
this.mount(win);
7979
})
8080
);
8181

8282
this.registerEvent(
83-
app.workspace.on('window-close', (_: any, win: Window) => {
83+
app.workspace.on('window-close', (_: unknown, win: Window) => {
8484
this.unmount(win);
8585
})
8686
);
@@ -112,7 +112,7 @@ export default class DBFolderPlugin extends Plugin {
112112
unload(): void {
113113
Promise.all(
114114
app.workspace.getLeavesOfType(DatabaseCore.FRONTMATTER_KEY).map((leaf) => {
115-
this.databaseFileModes[(leaf as any).id] = 'markdown';
115+
this.databaseFileModes[leaf.id] = 'markdown';
116116
return this.setMarkdownView(leaf);
117117
})
118118
).then(() => {
@@ -134,7 +134,7 @@ export default class DBFolderPlugin extends Plugin {
134134
this.windowRegistry.clear();
135135
this.databaseFileModes = {};
136136

137-
(app.workspace as any).unregisterHoverLinkSource(DatabaseCore.FRONTMATTER_KEY);
137+
app.workspace.unregisterHoverLinkSource(DatabaseCore.FRONTMATTER_KEY);
138138
}
139139

140140
/** Update plugin settings. */
@@ -179,7 +179,7 @@ export default class DBFolderPlugin extends Plugin {
179179

180180
viewStateReceivers: Array<(views: DatabaseView[]) => void> = [];
181181

182-
addView(view: DatabaseView, data: string) {
182+
addView(view: DatabaseView) {
183183
const win = view.getWindow();
184184
const reg = this.windowRegistry.get(win);
185185

@@ -371,7 +371,7 @@ export default class DBFolderPlugin extends Plugin {
371371
.setIcon(DB_ICONS.NAME)
372372
.setSection('pane')
373373
.onClick(() => {
374-
this.databaseFileModes[(leaf as any).id || file.path] =
374+
this.databaseFileModes[leaf.id || file.path] =
375375
DatabaseCore.FRONTMATTER_KEY;
376376
this.setDatabaseView(leaf);
377377
});
@@ -392,7 +392,7 @@ export default class DBFolderPlugin extends Plugin {
392392
.setIcon(DB_ICONS.NAME)
393393
.setSection('pane')
394394
.onClick(() => {
395-
this.databaseFileModes[(leaf as any).id || file.path] =
395+
this.databaseFileModes[leaf.id || file.path] =
396396
DatabaseCore.FRONTMATTER_KEY;
397397
this.setDatabaseView(leaf);
398398
});
@@ -406,7 +406,7 @@ export default class DBFolderPlugin extends Plugin {
406406
*/
407407
this.registerEvent(
408408
app.metadataCache.on("dataview:index-ready", async () => {
409-
for (const [win, { viewMap }] of Array.from(this.windowRegistry.entries())) {
409+
for (const [, { viewMap }] of Array.from(this.windowRegistry.entries())) {
410410
// Refresh all database views
411411
for (const view of viewMap.values()) {
412412
await view.reloadDatabase();
@@ -537,7 +537,7 @@ export default class DBFolderPlugin extends Plugin {
537537
}
538538

539539
showRibbonIcon() {
540-
this.ribbonIcon = this.addRibbonIcon(DB_ICONS.NAME, t("ribbon_icon_title"), async (e) => {
540+
this.ribbonIcon = this.addRibbonIcon(DB_ICONS.NAME, t("ribbon_icon_title"), async () => {
541541
new DatabaseHelperCreationModal(this.settings.local_settings).open()
542542
});
543543
}
@@ -607,7 +607,7 @@ export default class DBFolderPlugin extends Plugin {
607607
self.databaseFileModes[this.id || state.state.file] !== 'markdown'
608608
) {
609609
// Then check for the database frontMatterKey
610-
const cache = self.app.metadataCache.getCache(state.state.file);
610+
const cache = app.metadataCache.getCache(state.state.file);
611611

612612
if (cache?.frontmatter && cache.frontmatter[DatabaseCore.FRONTMATTER_KEY]) {
613613
// If we have it, force the view type to database

src/parsers/handlers/marshall/AbstractYamlPropertyHandler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { DatabaseYaml } from "cdm/DatabaseModel";
21
import { YamlHandler, YamlHandlerResponse } from "cdm/MashallModel";
32

43

src/parsers/handlers/marshall/MarshallConfigHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class MarshallConfigHandler extends AbstractYamlHandler {
3939
if (wrappedLiteral.type === "string") {
4040
unEscapedValue = unEscapeSpecialCharacters(wrappedLiteral.value)
4141
}
42-
localSettings[key] = unEscapedValue as any;
42+
localSettings[key] = unEscapedValue as LocalSettings[K];
4343
return localSettings;
4444
}
4545

@@ -49,7 +49,7 @@ export class MarshallConfigHandler extends AbstractYamlHandler {
4949

5050
parseBoolean<K extends keyof LocalSettings>(key: K, localSettings: LocalSettings): LocalSettings {
5151
const parsedValue = localSettings[key].toString().toLowerCase() === 'true';
52-
localSettings[key] = parsedValue as any;
52+
localSettings[key] = parsedValue as LocalSettings[K];
5353
return localSettings;
5454
}
5555
}

src/parsers/handlers/unmarshall/UnmarshallFiltersHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class UnmarshallFiltersHandler extends AbstractDiskHandler {
2323

2424
return this.goNext(handlerResponse);
2525
}
26-
striginifyFilter(filter: FilterGroup, indentLevel: number, isList = false): void {
26+
striginifyFilter(filter: FilterGroup, indentLevel: number): void {
2727
if ((filter as FilterGroupCondition).condition) {
2828
// Is a filter group
2929
const condition = (filter as FilterGroupCondition).condition;
@@ -45,7 +45,7 @@ export class UnmarshallFiltersHandler extends AbstractDiskHandler {
4545
this.localDisk.push(`${YAML_INDENT.repeat(indentLevel)} filters:`);
4646
indentLevel++;
4747
for (const group of (filter as FilterGroupCondition).filters) {
48-
this.striginifyFilter(group, indentLevel, true);
48+
this.striginifyFilter(group, indentLevel);
4949
}
5050
}
5151
} else {

src/stateManagement/automations/handlers/DispatchRollupHandlerAction.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Rollup from "lib/Rollup";
22
import { ConfigColumn } from "cdm/FolderModel";
3-
import { LocalSettings } from "cdm/SettingsModel";
43
import { AutomationState, TableActionResponse } from "cdm/TableStateInterface";
54
import { Link, Literal } from "obsidian-dataview";
65
import { DataviewService } from "services/DataviewService";

0 commit comments

Comments
 (0)