HumanCellAtlas/ingest-validator

View on GitHub

Showing 14 of 22 total issues

Function _generateKeywordFunction has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    static _generateKeywordFunction() : SchemaValidateFunction {

        const olsConnectionConfig: any = config.get("OLS_API.connection");
        const olsSearchUrl = olsConnectionConfig["scheme"] + "://" + olsConnectionConfig["host"] + ":" + olsConnectionConfig["port"] + "/api/search?q="
        const cachedOlsResponses: {[key: string]: Promise<any>} = {};
Severity: Major
Found in src/custom/graph-restriction.ts - About 3 hrs to fix

    IngestClient has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class IngestClient extends Client {
    
        constructor(connectionConfig: IngestConnectionProperties) {
            const ingestUrl = `${connectionConfig.scheme}://${connectionConfig.host}:${connectionConfig.port}`;
            super(ingestUrl);
    Severity: Minor
    Found in src/utils/ingest-client/ingest-client.ts - About 2 hrs to fix

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

              const findChildTerm = (schema: any, data: any, parentSchema:any, dataPath:any) => {
                  return new Promise((resolve, reject) => {
                      let parentTerms = schema.classes;
                      const ontologyIds = schema.ontologies;
                      let errors: ErrorObject[]  = [];
      Severity: Major
      Found in src/custom/graph-restriction.ts - About 2 hrs to fix

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

            static _generateKeywordFunction() : SchemaValidateFunction {
        
                const olsConnectionConfig: any = config.get("OLS_API.connection");
                const olsSearchUrl = olsConnectionConfig["scheme"] + "://" + olsConnectionConfig["host"] + ":" + olsConnectionConfig["port"] + "/api/search?q="
                const cachedOlsResponses: {[key: string]: Promise<any>} = {};
        Severity: Minor
        Found in src/custom/graph-restriction.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 handle has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            handle(msg: string): Promise<boolean> {
                return new Promise<boolean>((resolve, reject) => {
                    let msgContent: any = null;
                    try {
                        msgContent = JSON.parse(msg);
        Severity: Minor
        Found in src/listener/handlers/file-validation-handler.ts - About 1 hr to fix

          Function constructUserFriendlyMessage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              constructUserFriendlyMessage() : void {
                  if(this.absoluteDataPath === null) {
                      throw new Error("Can't construct a user friendly message: absoluteDataPath of error not set");
                  } else if(!this.message) {
                      throw new Error("Can't construct a user friendly message: error message not set");
          Severity: Minor
          Found in src/model/error-report.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 attemptFileValidation has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              attemptFileValidation(contentValidationReport: ValidationReport, fileDocument: any, documentType: string) : Promise<ValidationReport> {
                  // proceed with data file validation if metadata doc validation passes
                  if(documentType.toUpperCase() === 'FILE' && contentValidationReport.validationState.toUpperCase() == "VALID") {
                      const fileName = fileDocument['fileName'];
                      const fileFormat = IngestValidator.fileFormatFromFileName(fileName);
          Severity: Minor
          Found in src/validation/ingest-validator.ts - About 1 hr to fix

            Function start has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                start(){
                    amqp.connect(String(this.rabbitUrl)).then((conn) => {
                        return conn.createChannel();
                    }).then(ch => {
                        ch.assertExchange(this.rabbitMessagingProperties.exchange, this.rabbitMessagingProperties.exchangeType).then(() => {
            Severity: Minor
            Found in src/listener/listener.ts - About 1 hr to fix

              Function validateFile has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  validateFile(fileResource: any, fileFormat: string, fileName: string) : Promise<ValidationJob> {
              
                      const validationJob = fileResource["validationJob"];
                      const fileChecksums = fileResource["checksums"];
              
              
              Severity: Minor
              Found in src/utils/ingest-client/ingest-file-validator.ts - About 1 hr to fix

                Function _handle has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    _handle(msgJson: any): Promise<any> {
                        const callbackLink = msgJson['callbackLink'];
                        const documentUrl = this.ingestClient.urlForCallbackLink(callbackLink);
                        const documentType = msgJson['documentType'].toUpperCase();
                
                
                Severity: Minor
                Found in src/listener/handlers/document-update-handler.ts - About 1 hr to fix

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

                      validateSingleSchema(inputSchema: any, inputObject: any) : Promise<ErrorObject[]> {
                          inputSchema["$async"] = true;
                          const schemaId: string = inputSchema['$id'];
                  
                          return new Promise((resolve, reject) => {
                  Severity: Minor
                  Found in src/validation/schema-validator.ts - About 1 hr to fix

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

                        expandCurie(term: string) {
                            const termUri = encodeURIComponent(term);
                            const url = olsSearchUrl + termUri
                                + "&exact=true&groupField=true&queryFields=obo_id";
                    
                    
                    Severity: Minor
                    Found in src/utils/curie-expansion.ts - About 1 hr to fix

                      Function validateFile has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          validateFile(fileResource: any, fileFormat: string, fileName: string) : Promise<ValidationJob> {
                      
                              const validationJob = fileResource["validationJob"];
                              const fileChecksums = fileResource["checksums"];
                      
                      
                      Severity: Minor
                      Found in src/utils/ingest-client/ingest-file-validator.ts - About 55 mins 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 _isResourceEligible has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          static _isResourceEligible(resource: any, resourceType: string): boolean {
                              if(! FastqValidator._isFile(resourceType)) {
                                  return false;
                              } else {
                                  try {
                      Severity: Minor
                      Found in src/validation/fastq/fastq-validator.ts - About 45 mins 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

                      Severity
                      Category
                      Status
                      Source
                      Language