HumanCellAtlas/ingest-validator

View on GitHub

Showing 22 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

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        constructor(rabbitConnectionProperties: RabbitConnectionProperties, rabbitMessagingProperties: RabbitMessagingProperties, handler: IHandler) {
            this.rabbitConnectionProperties = rabbitConnectionProperties;
            this.rabbitMessagingProperties = rabbitMessagingProperties;
            this.handler = handler;
    
    
    Severity: Major
    Found in src/listener/file-validation-listener.ts and 1 other location - About 3 hrs to fix
    src/listener/document-update-listener.ts on lines 15..21

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 97.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

        constructor(rabbitConnectionProperties: RabbitConnectionProperties, rabbitMessagingProperties: RabbitMessagingProperties, handler: IHandler) {
            this.rabbitConnectionProperties = rabbitConnectionProperties;
            this.rabbitMessagingProperties = rabbitMessagingProperties;
            this.handler = handler;
            this.listener = new Listener(rabbitConnectionProperties, rabbitMessagingProperties);
    Severity: Major
    Found in src/listener/document-update-listener.ts and 1 other location - About 3 hrs to fix
    src/listener/file-validation-listener.ts on lines 15..22

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 97.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          static _getProtocolsForProcess(processUrl: string, ingestClient: IngestClient) : Promise<MetadataResource[]> {
              return new Promise<MetadataResource[]>((resolve, reject) => {
                  ingestClient.retrieveEmbeddedEntities(processUrl, "protocols", "protocols").then(protocols => {
                      resolve(R.map(derivedProcess => FastqValidator._parseMetadataResource(derivedProcess), protocols));
                  });
      Severity: Major
      Found in src/validation/fastq/fastq-validator.ts and 1 other location - About 2 hrs to fix
      src/validation/fastq/fastq-validator.ts on lines 127..133

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 81.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          static _getDerivedProcessesForFile(fileUrl: string, ingestClient: IngestClient) : Promise<MetadataResource[]> {
              return new Promise<MetadataResource[]>((resolve, reject) => {
                  ingestClient.retrieveEmbeddedEntities(fileUrl, "derivedProcesses", "processes").then(derivedProcesses => {
                          resolve(R.map(derivedProcess => FastqValidator._parseMetadataResource(derivedProcess), derivedProcesses));
                  });
      Severity: Major
      Found in src/validation/fastq/fastq-validator.ts and 1 other location - About 2 hrs to fix
      src/validation/fastq/fastq-validator.ts on lines 135..141

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 81.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            getValidationJob(fileDocumentUrl: string) : Promise<ValidationJob> {
                return this
                    .retrieveMetadataDocument(fileDocumentUrl)
                    .then(fileResource => {return Promise.resolve(fileResource["validationJob"] as ValidationJob)});
            }
        Severity: Major
        Found in src/utils/ingest-client/ingest-client.ts and 1 other location - About 1 hr to fix
        src/utils/ingest-client/ingest-client.ts on lines 241..245

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 71.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            getFileChecksums(fileDocumentUrl: string) : Promise<FileChecksums> {
                return this
                    .retrieveMetadataDocument(fileDocumentUrl)
                    .then(fileResource => {return Promise.resolve(fileResource["checksums"] as FileChecksums)});
            }
        Severity: Major
        Found in src/utils/ingest-client/ingest-client.ts and 1 other location - About 1 hr to fix
        src/utils/ingest-client/ingest-client.ts on lines 247..251

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 71.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

                      Similar blocks of code found in 2 locations. Consider refactoring.
                      Open

                                                      } catch (e) {
                                                          console.error(`Logging unexpected exception: \n ${e.stack} \n ..for message: ${msg!.content}`);
                                                          ch.ack(msg!)
                                                      }
                      Severity: Minor
                      Found in src/listener/listener.ts and 1 other location - About 50 mins to fix
                      src/listener/listener.ts on lines 45..48

                      Duplicated Code

                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                      Tuning

                      This issue has a mass of 51.

                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                      Refactorings

                      Further Reading

                      Severity
                      Category
                      Status
                      Source
                      Language