microsoft / sarif-js-sdk

JavaScript code and supporting files for working with the 'Static Analysis Results Interchange Format' (SARIF, see https://github.com/oasis-tcs/sarif-spec)
MIT License
26 stars 13 forks source link

Add no rule metadata test case to sarif-test and fix that test failure. #27

Closed zhanwang626 closed 3 years ago

zhanwang626 commented 3 years ago

Summary

Add a no metadata rule test case that mentioned in Issue #26 and fix it.

Test

Npm test done.

 PASS  __tests__/sarif-test.js
  formatter:sarif
    when run
      ✓ should return a log with correct SARIF version and tool metadata (143 ms)
    when eslint version is known
      ✓ should return correct eslint version
    when passed no messages
      ✓ should return a log with files, but no results (1 ms)
    when passed one message
      ✓ should return a log with one file and one result (1 ms)
    when passed one message with a rule id
      ✓ should return a log with one rule (1 ms)
    when passed one message with line but no column nor source string
      ✓ should return a log with one result whose location region has only a startLine (4 ms)
    when passed one message with line and invalid column
      ✓ should return a log with one result whose location contains a region with line # and no column #
    when passed one message with line and column but no source string
      ✓ should return a log with one result whose location contains a region with line and column #s (1 ms)
    when passed one message with line, column, and source string
      ✓ should return a log with one result whose location contains a region with line and column #s
    when passed one message with a source string but without line and column #s
      ✓ should return a log with one result whose location contains a region with line and column #s (1 ms)
    when passed two results with two messages each
      ✓ should return a log with two files, three rules, and four results (3 ms)
    when passed two results with one having no message and one with two messages
      ✓ should return a log with two files, two rules, and two results (2 ms)
    when passed a result with no rule id
      ✓ should return a log with no rules, no results, and a tool execution notification (1 ms)
    when passed a rule with no description
      ✓ should return a log with one file, one rule, and one result (1 ms)
    when passed rules without metadata
      ✓ should return a log with one rule

Test Suites: 1 passed, 1 total
Tests:       15 passed, 15 total
Snapshots:   0 total
Time:        2.171 s
Ran all test suites.
ghost commented 3 years ago

CLA assistant check
All CLA requirements met.