Skip to content

Commit

Permalink
[Misc] Enforce a limit of 10 statements per method body
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelleduc committed Dec 17, 2024
1 parent 08344f0 commit 32f0b43
Show file tree
Hide file tree
Showing 50 changed files with 137 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/src/components/defaultWikiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ export class DefaultWikiConfig implements WikiConfig {
this.designSystem = configObject.designSystem;
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
setupOfflineStorage(): void {
this.logger.debug("Checking offline storage");
if (this.offline && this.cristal) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class DefaultAttachmentPreview implements AttachmentPreview {
this.refs = storeToRefs(this.store);
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async preview(attachmentReference: AttachmentReference): Promise<void> {
this.store.startLoading();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export class XWikiAuthenticationManager implements AuthenticationManager {

private readonly accessTokenCookieKeyPrefix = "accessToken";

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
start(): void {
const config = this.cristalApp.getWikiConfig();
const authorizationUrl = new URL(`${config.baseURL}/oidc/authorization`);
Expand All @@ -71,6 +73,8 @@ export class XWikiAuthenticationManager implements AuthenticationManager {
window.location.href = authorizationUrl.toString();
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async callback(): Promise<void> {
const href = new URL(window.location.href);
const code = href.searchParams.get("code");
Expand Down
4 changes: 4 additions & 0 deletions core/backends/backend-dexie/src/wrappingOfflineStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export class WrappingOfflineStorage implements WrappingStorage {
return this.storage.getImageURL(page, image);
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
public async getPageContent(
page: string,
syntax: string,
Expand Down Expand Up @@ -151,6 +153,8 @@ export class WrappingOfflineStorage implements WrappingStorage {
}
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
public async updatePageContent(
page: string,
syntax: string,
Expand Down
2 changes: 2 additions & 0 deletions core/backends/backend-github/src/githubStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export class GitHubStorage extends AbstractStorage {
return "" + hash;
};

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async getPageContent(
page: string,
syntax: string,
Expand Down
2 changes: 2 additions & 0 deletions core/backends/backend-nextcloud/src/nextcloudStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export class NextcloudStorage extends AbstractStorage {
}
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async getAttachments(page: string): Promise<AttachmentsData | undefined> {
const response = await fetch(this.getAttachmentsBasePath(page), {
method: "PROPFIND",
Expand Down
6 changes: 6 additions & 0 deletions core/backends/backend-xwiki/src/xwikiStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ export class XWikiStorage extends AbstractStorage {
return imageURL;
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async getPageContent(
page: string,
syntax: string,
Expand Down Expand Up @@ -219,6 +221,8 @@ export class XWikiStorage extends AbstractStorage {
}
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async getPanelContent(panel: string, contextPage: string): Promise<PageData> {
const url =
this.wikiConfig.baseURL +
Expand All @@ -239,6 +243,8 @@ export class XWikiStorage extends AbstractStorage {
return panelContentData;
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async getEditField(document: Document, fieldName: string): Promise<string> {
// http://localhost:15680/xwiki/bin/get/Blog/BlogIntroduction?xpage=display&mode=edit&property=Blog.BlogPostClass.category
// http://localhost:15680/xwiki/bin/get/Help/Applications/Movies/Modern%20Times?xpage=display&mode=edit&property=Help.Applications.Movies.Code.MoviesClass%5B0%5D.staticList1&type=object&language=
Expand Down
2 changes: 2 additions & 0 deletions core/document/document-default/src/defaultDocumentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ function createStore(cristal: CristalApp): DocumentStoreDefinition {
this.document = undefined;
this.error = undefined;
},
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async update(
documentReference: string,
requeue: boolean,
Expand Down
2 changes: 2 additions & 0 deletions core/hierarchy/hierarchy-default/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import type { PageHierarchyItem } from "@xwiki/cristal-hierarchy-api";
* @returns the page hierarchy
* @since 0.10
**/
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
export async function getPageHierarchyFromPath(
pageData: PageData,
cristalApp: CristalApp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class XWikiPageHierarchyResolver implements PageHierarchyResolver {
this.logger.setModule("storage.components.XWikiPageHierarchyResolver");
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async getPageHierarchy(
pageData: PageData,
): Promise<Array<PageHierarchyItem>> {
Expand Down
2 changes: 2 additions & 0 deletions core/history/history-github/src/components/componentsInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class GitHubPageRevisionManager implements PageRevisionManager {
this.logger.setModule("history-github.GitHubPageRevisionManager");
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async getRevisions(pageData: PageData): Promise<Array<PageRevision>> {
const revisions: Array<PageRevision> = [];
if (pageData) {
Expand Down
4 changes: 4 additions & 0 deletions core/history/history-xwiki/src/components/componentsInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class XWikiPageRevisionManager implements PageRevisionManager {
this.logger.setModule("history.xwiki.XWikiPageRevisionManager");
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async getRevisions(
pageData: PageData,
limit?: number,
Expand Down Expand Up @@ -135,6 +137,8 @@ class XWikiPageRevisionManager implements PageRevisionManager {
}
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
private async getUserName(userId: string): Promise<UserDetails> {
const restApiUrl =
getRestSpacesApiUrl(this.cristalApp.getWikiConfig(), userId) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export class NextcloudLinkSuggestService implements LinkSuggestService {
@inject<CristalApp>("CristalApp") private readonly cristalApp: CristalApp,
) {}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async getLinks(query: string): Promise<Link[]> {
const baseRestURL = this.cristalApp
.getWikiConfig()
Expand Down
2 changes: 2 additions & 0 deletions core/model/model-click-listener/src/DefaultClickListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class DefaultClickListener implements ClickListener {
);
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
handleURL(url: string, href?: string): void {
const remoteURLParser = this.remoteURLParserProvider.get()!;
const modelReferenceSerializer =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import { injectable } from "inversify";
export class FileSystemModelReferenceSerializer
implements ModelReferenceSerializer
{
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
serialize(reference?: EntityReference): string | undefined {
if (!reference) {
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import { injectable } from "inversify";
export class NextcloudModelReferenceSerializer
implements ModelReferenceSerializer
{
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
serialize(reference?: EntityReference): string | undefined {
if (!reference) {
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export class XWikiModelReferenceSerializer implements ModelReferenceSerializer {
return segment.replace(/(\.|\\)/g, "\\$1");
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
serialize(reference?: EntityReference): string | undefined {
if (!reference) {
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { injectable } from "inversify";

@injectable()
class FileSystemRemoteURLParser implements RemoteURLParser {
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
parse(urlStr: string): EntityReference | undefined {
const startWithFilesystemProtocol = urlStr.startsWith(`${protocol}://`);
if (!startWithFilesystemProtocol && urlStr.includes("://")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class XWikiRemoteURLParser implements RemoteURLParser {
@inject<CristalApp>("CristalApp") private readonly cristalApp: CristalApp,
) {}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
parse(urlStr: string): EntityReference {
const baseURLstr = this.cristalApp.getWikiConfig().baseURL;
if (!urlStr.startsWith(baseURLstr)) {
Expand Down
2 changes: 2 additions & 0 deletions core/navigation-tree/navigation-tree-default/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import type { PageData } from "@xwiki/cristal-api";
* @returns the parents nodes ids
* @since 0.10
**/
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
export function getParentNodesIdFromPath(page?: PageData): Array<string> {
const result: Array<string> = [];
if (page) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class GitHubNavigationTreeSource implements NavigationTreeSource {
this.cristalApp = cristalApp;
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async getChildNodes(id?: string): Promise<Array<NavigationTreeNode>> {
const currentId = id ? id : "";
const navigationTree: Array<NavigationTreeNode> = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ class NextcloudNavigationTreeSource implements NavigationTreeSource {
return navigationTree;
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
private async getSubDirectories(directory: string): Promise<Array<string>> {
const subdirectories: Array<string> = [];
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class XWikiNavigationTreeSource implements NavigationTreeSource {
);
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async getChildNodes(id?: string): Promise<Array<NavigationTreeNode>> {
const currentId = id ? id : "#";
const navigationTree: Array<NavigationTreeNode> = [];
Expand All @@ -78,6 +80,8 @@ class XWikiNavigationTreeSource implements NavigationTreeSource {
return navigationTree;
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
getParentNodesId(page?: PageData): Array<string> {
const result = [];
if (page) {
Expand Down Expand Up @@ -105,6 +109,8 @@ class XWikiNavigationTreeSource implements NavigationTreeSource {
return result;
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
private async fetchNodes(
currentId: string,
headers: { Accept: string; Authorization?: string },
Expand Down
2 changes: 2 additions & 0 deletions core/page-actions/page-actions-ui/src/vue/DeletePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const documentService = cristal
.get<DocumentService>("DocumentService");
const deleteDialogOpen: Ref<boolean> = ref(false);

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async function deletePage() {
const hierarchy: Array<PageHierarchyItem> = await cristal
.getContainer()
Expand Down
2 changes: 2 additions & 0 deletions ds/dsfr/src/components/dsfrDesignSystemLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import type { App } from "vue";

@injectable()
export class DSFRDesignSystemLoader implements DesignSystemLoader {
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
loadDesignSystem(app: App): void {
// Loading specific components from DSFR
app.use(VueDsfr);
Expand Down
2 changes: 2 additions & 0 deletions ds/shoelace/src/components/shoelaceDesignSystemLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import type { App } from "vue";

@injectable()
export class ShoelaceDesignSystemLoader implements DesignSystemLoader {
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
loadDesignSystem(app: App): void {
registerAsyncComponent(app, "XLoad", () => import("../vue/x-load.vue"));
registerAsyncComponent(app, "XAvatar", () => import("../vue/x-avatar.vue"));
Expand Down
2 changes: 2 additions & 0 deletions ds/shoelace/src/vue/__tests__/x-alert.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { shallowMount } from "@vue/test-utils";
import { describe, expect, it } from "vitest";

describe("x-alert", () => {
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
it("has a description", () => {
const xAlert = shallowMount(XAlert, {
props: {
Expand Down
4 changes: 4 additions & 0 deletions ds/shoelace/src/vue/x-navigation-tree-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ async function lazyLoadChildren() {
current.value?.removeAttribute("lazy");
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async function expandTree(nodesToExpand: string[]) {
if (nodesToExpand[0] == props.node.id) {
if (nodesToExpand.length > 1) {
Expand Down Expand Up @@ -128,6 +130,8 @@ function onDocumentDelete(parents: string[]) {
}
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async function onDocumentUpdate(parents: string[]) {
for (const i of nodes.value.keys()) {
if (nodes.value[i].id == parents[0]) {
Expand Down
2 changes: 2 additions & 0 deletions ds/shoelace/src/vue/x-navigation-tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ async function onDocumentDelete(page: PageData) {
}
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async function onDocumentUpdate(page: PageData) {
const parents = treeSource.getParentNodesId(page);

Expand Down
2 changes: 2 additions & 0 deletions ds/vuetify/src/components/vuetifyDesignSystemLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import type { App } from "vue";

@injectable()
export class VuetifyDesignSystemLoader implements DesignSystemLoader {
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
loadDesignSystem(app: App): void {
/*
// Manuel importing to reduce build size
Expand Down
6 changes: 6 additions & 0 deletions ds/vuetify/src/vue/x-navigation-tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ onBeforeMount(async () => {

watch(() => props.currentPage, expandTree);

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async function expandTree() {
if (props.currentPage && !isExpanding) {
isExpanding = true;
Expand Down Expand Up @@ -160,6 +162,8 @@ function clearSelection() {
}
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async function onDocumentDelete(page: PageData) {
const parents = treeSource.getParentNodesId(page);
let currentItems: TreeItem[] | undefined = rootNodes.value;
Expand All @@ -179,6 +183,8 @@ async function onDocumentDelete(page: PageData) {
}
}

// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async function onDocumentUpdate(page: PageData) {
const parents = treeSource.getParentNodesId(page);
let currentParent: string | undefined = undefined;
Expand Down
5 changes: 4 additions & 1 deletion editors/tiptap/src/components/extensions/link-suggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ function loadLinkSuggest(
/**
* Build a function returning an array of link suggestions from a string.
* @param linkSuggest - the link suggestion service to use
* @param wikiConfig - the wiki configuration to use
*/
function initSuggestionsService(linkSuggest: LinkSuggestService | undefined) {
// Return an array of suggestions from a query
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
return async function ({
query,
}: {
Expand Down Expand Up @@ -186,6 +187,8 @@ function renderItems(

return false;
},
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
onStart(props: {
items: LinkSuggestionActionDescriptor[];
editor: Editor;
Expand Down
2 changes: 2 additions & 0 deletions editors/tiptap/src/extensions/autoSaver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class AutoSaver extends EventEmitter {
/**
* @param providedAuthors - provide a set of user when manually triggering this save.
*/
// TODO: reduce the number of statements in the following method and reactivate the disabled eslint rule.
// eslint-disable-next-line max-statements
async save(providedAuthors?: User[]): Promise<void> {
const authors = providedAuthors ?? this.getAuthors();
if (authors.length == 0) {
Expand Down
Loading

0 comments on commit 32f0b43

Please sign in to comment.