Skip to content

Improve warning message: Warning: Did not find any lines of code in database #5838

Closed
github/codeql-action
#483

Description

@mariusingjer

Description of the issue

I am getting a warning in my codeql build which I have no idea what means, and google is not helping either.

image

Suggestion: give some more context to this warning, what does it mean?

Activity

  1. mariusingjer commented on May 5, 2021

    @mariusingjer
    Author

    The error message stems from this file:
    https://github.com/github/codeql-action/blob/1585462c63bbf1fe66558b776baebdf15cea0f3a/src/count-loc.ts

    ..still gets me wondering though

  2. self-assigned this
    on May 5, 2021
  3. aeisenberg commented on May 5, 2021

    @aeisenberg
    Contributor

    We have recently introduced a baseline lines of code counter for the source code in your scan. We're using this as part of a larger feature to gather metrics about the repository being scanned.

    In your case, for some reason, code scanning did not find any lines of code (it doesn't mean that your repository wasn't scanned, just that our LoC counter found nothing). It could be a bug. Though, it's hard to track this down without knowing a bit more about your repository. Is it public? If not, can you share a (sanitized) version of your code scanning workflow?

  4. mariusingjer commented on May 5, 2021

    @mariusingjer
    Author
    jobs:
      analyze:
        name: Analyze
        runs-on: ubuntu-latest
        strategy:
          fail-fast: true
          matrix:
            language: [ 'csharp', 'javascript' ]
            include:
              - language: 'csharp'
                config: './.github/workflows/codeql-config-dotnet.yaml'
              - language: 'javascript'
                config: './.github/workflows/codeql-config-javascript.yaml'
        steps:
        - name: Checkout repository
          uses: actions/checkout@v2
        - name: Initialize CodeQL
          uses: github/codeql-action/init@v1
          with:
            languages: ${{ matrix.language }}
            config-file: ${{ matrix.config }}
        - if: matrix.language == 'csharp'
          name: Autobuild
          uses: github/codeql-action/autobuild@v1
        - name: Perform CodeQL Analysis
          uses: github/codeql-action/analyze@v1
    

    I had to use configs in order to do path filtering since this is a mono-repo and thats the only way I was able to specify paths to scan, but I don't think its relevant for the warning since the warning message first appeared in builds 3 days ago, and I didn't use config files in those builds. I've looked at builds from 6 days old and the error message is not there.

    name: "dotnet codeql config"
    
    paths:
      - src
      - database
    

    and

    name: "javascript codeql config"
    
    paths:
      - pipeline
      - pipeline-lambdas
    
  5. aeisenberg commented on May 5, 2021

    @aeisenberg
    Contributor

    Thanks. This is useful. I'll see if I can get some way to reproduce.

  6. mariusingjer commented on May 6, 2021

    @mariusingjer
    Author

    I just very quickly looked at the code, and I guess it can't be this simple, but I noticed that the values (which are the keys in the reversemap) doesn't match the languages. Could this be a bug?

    analyze.ts:

      const locPromise = countLoc(
        path.resolve(),
        // config.paths specifies external directories. the current
        // directory is included in the analysis by default. Replicate
        // that here.
        config.paths,
        config.pathsIgnore,
        config.languages,
        logger
      );
    

    count-loc.ts

    const supportedLanguages = {
      c: "cpp",
      "c++": "cpp",
      "c#": "cs",
      go: "go",
      java: "java",
      javascript: "js",
      python: "py",
      ruby: "rb",
      typescript: "js",
    };
    
    const supportedLanguagesReversed = Object.entries(supportedLanguages).reduce(
      (obj, [key, value]) => {
        if (!obj[value]) {
          obj[value] = [];
        }
        obj[value].push(key);
        return obj;
      },
      {}
    );
    
    analysisLanguages: dbLanguages.flatMap(
      (lang) => supportedLanguagesReversed[lang]
    )
    

    languages.ts:

    // All the languages supported by CodeQL
    export enum Language {
      csharp = "csharp",
      cpp = "cpp",
      go = "go",
      java = "java",
      javascript = "javascript",
      python = "python",
    }
    
  7. aeisenberg commented on May 6, 2021

    @aeisenberg
    Contributor

    Thanks for taking a deeper look into this. I'm not able to verify at this moment, but it's possible you've found the problem.

  8. tschaub commented on May 7, 2021

    @tschaub

    Perhaps this is a totally unrelated project, but Googling for this "Did not find any lines of code in database" turns up examples like this: https://github.com/github/codeql-action/actions/runs/797613079

  9. RA80533 commented on May 7, 2021

    @RA80533

    countLoc (definition) appears to be typed incorrectly based on how it is used in analyze.ts; specifically, dbLanguages is widened from Language[] to string[].

  10. aeisenberg commented on May 7, 2021

    @aeisenberg
    Contributor

    Thanks all for pointing this out. This will be fixed next time we release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions