OpenHPS/openhps-solid

View on GitHub

Showing 21 of 37 total issues

File SolidService.ts has 619 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
    DataFrame,
    DataObject,
    DataServiceDriver,
    MemoryDataService,
Severity: Major
Found in src/common/SolidService.ts - About 1 day to fix

    Function handleRedirect has 114 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected async handleRedirect(session?: SolidSession): Promise<ISessionInfo> {
            try {
                const url = new URL(window.location.href);
                // Check if can process
                if (url.searchParams.get('code') === null && url.searchParams.get('state') === null) {
    Severity: Major
    Found in src/browser/SolidClientService.ts - About 4 hrs to fix

      SolidService has 31 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export abstract class SolidService extends RemoteService {
          protected options: SolidDataServiceOptions;
          storage: IStorage;
          protected storageUtility: StorageUtility;
          readonly clientRegistrar: ClientRegistrar;
      Severity: Minor
      Found in src/common/SolidService.ts - About 3 hrs to fix

        Function getDatasetStore has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            getDatasetStore(session: SolidSession, uri: string): Promise<Store> {
                return new Promise((resolve, reject) => {
                    /**
                     *
                     * @param subject
        Severity: Major
        Found in src/common/SolidService.ts - About 2 hrs to fix

          Function insert has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              insert(_, object: T): Promise<T> {
                  return new Promise((resolve, reject) => {
                      if (!object.webId) {
                          if (this.service.session) {
                              object.webId = this.service.session.info.webId;
          Severity: Major
          Found in src/common/SolidDataDriver.ts - About 2 hrs to fix

            File SolidDataDriver.ts has 259 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import { DataFrame, DataObject, Model, Constructor, FindOptions, FilterQuery, Serializable } from '@openhps/core';
            import { SolidService, SolidSession } from './SolidService';
            import { getSolidDataset, removeThing, saveSolidDatasetAt, Thing } from '@inrupt/solid-client';
            import {
                RDFSerializer,
            Severity: Minor
            Found in src/common/SolidDataDriver.ts - About 2 hrs to fix

              File SolidClientService.ts has 258 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import { ISessionInfo, ISessionOptions, IStorage, Session } from '@inrupt/solid-client-authn-browser';
              import { SolidProfileObject } from '../common';
              import { SolidService, SolidDataServiceOptions, SolidSession, ISessionInternalInfo } from '../common/SolidService';
              import {
                  buildAuthenticatedFetch,
              Severity: Minor
              Found in src/browser/SolidClientService.ts - About 2 hrs to fix

                Function handleLogin has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    handleLogin(): Promise<SolidSession> {
                        return new Promise((resolve, reject) => {
                            let storedSessionData: ISessionInfo & ISessionInternalInfo = undefined;
                            let session: SolidSession = undefined;
                            let sessionId: string = undefined;
                Severity: Major
                Found in src/browser/SolidClientService.ts - About 2 hrs to fix

                  Function handleRedirect has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected async handleRedirect(session?: SolidSession): Promise<ISessionInfo> {
                          try {
                              const url = new URL(window.location.href);
                              // Check if can process
                              if (url.searchParams.get('code') === null && url.searchParams.get('state') === null) {
                  Severity: Minor
                  Found in src/browser/SolidClientService.ts - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Function login has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      login(oidcIssuer: string = this.options.defaultOidcIssuer, interactive: boolean = false): Promise<Session> {
                          const session = this.createSession({
                              storage: this.storage,
                          });
                          if (!interactive) {
                  Severity: Minor
                  Found in src/node/SolidClientService.ts - About 1 hr to fix

                    Function convertPredicates has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                                function convertPredicates(subject: Quad_Subject, predicates: any): Quad[] {
                                    return Object.keys(predicates)
                                        .map((key) => {
                                            const predicate = DataFactory.namedNode(key);
                                            const objects: Quad_Object[] = [];
                    Severity: Minor
                    Found in src/common/SolidService.ts - About 1 hr to fix

                      Function getClient has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          async getClient(options: IClientRegistrarOptions, issuerConfig: IIssuerConfig): Promise<IClient> {
                              // If client secret and/or client id are stored in storage, use those.
                              const [storedClientId, storedClientSecret, storedClientName, storedClientType] = await Promise.all([
                                  this.storageUtility.getForUser(options.sessionId, 'clientId', {
                                      secure: false,
                      Severity: Minor
                      Found in src/common/ClientRegistrar.ts - About 1 hr to fix

                        Function bundle has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                        const bundle = (env, module, entry = 'index', suffix = '') => {
                          const filename = `${PROJECT_NAME}${suffix}${module ? ".es" : ""}${env.prod ? ".min" : ""}`;
                          return {
                            name: PROJECT_NAME,
                            entry: `./dist/esm5/${entry}.js`,
                        Severity: Minor
                        Found in webpack.config.js - About 1 hr to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function bundle has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const bundle = (env, module, entry = 'index', suffix = '') => {
                          const filename = `${PROJECT_NAME}${suffix}${module ? ".es" : ""}${env.prod ? ".min" : ""}`;
                          return {
                            name: PROJECT_NAME,
                            entry: `./dist/esm5/${entry}.js`,
                        Severity: Minor
                        Found in webpack.config.js - About 1 hr to fix

                          Function storeProfile has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              storeProfile(object: SolidProfileObject): Promise<SolidProfileObject> {
                                  return new Promise((resolve, reject) => {
                                      const key = `${SolidService.PREFIX}:webId:${object.webId}`;
                                      this.storage
                                          .set(key, object.sessionId)
                          Severity: Minor
                          Found in src/common/SolidService.ts - About 1 hr to fix

                            Function loginSuccessCallback has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                loginSuccessCallback: async function(req: express.Request, res: express.Response, sessionInfo: any) {
                                  const service: SolidService = this;
                            
                                  const session = await service.findSessionByWebId(sessionInfo.webId);
                                  const card = await service.getThing(session, sessionInfo.webId);
                            Severity: Minor
                            Found in examples/server/src/index.ts - About 1 hr to fix

                              Function findSessionById has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  findSessionById(sessionId: string): Promise<SolidSession> {
                                      return new Promise((resolve, reject) => {
                                          let session: SolidSession = undefined;
                                          this.findSessionInfoById(sessionId)
                                              .then((sessionInfo) => {
                              Severity: Minor
                              Found in src/common/SolidService.ts - About 1 hr to fix

                                Function _onBuild has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    private _onBuild(): Promise<void> {
                                        return new Promise((resolve, reject) => {
                                            if (this.options.authServer) {
                                                if (!Object.keys(this.options.authServer).includes('port')) {
                                                    this.express = this.options.authServer as express.Express;
                                Severity: Minor
                                Found in src/node/SolidClientService.ts - About 1 hr to fix

                                  Function delete has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      delete(id: string): Promise<void> {
                                          return new Promise((resolve, reject) => {
                                              let uri: IriString;
                                              let currentSession: SolidSession;
                                              this.service
                                  Severity: Minor
                                  Found in src/common/SolidDataDriver.ts - About 1 hr to fix

                                    Function createThing has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        createThing(session: SolidSession, thing: Thing, dataset?: SolidDataset): Promise<SolidDataset> {
                                            return new Promise((resolve, reject) => {
                                                const documentURL = new URL(thing.url);
                                                documentURL.hash = '';
                                                /**
                                    Severity: Minor
                                    Found in src/common/SolidService.ts - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language