Skip to content

Commit

Permalink
fix: show warning when unsupported languages are detected (#1271)
Browse files Browse the repository at this point in the history
* fix: show warning when unsupported languages are detected

* fix: add detector lang to dependency

* fix: update test helper in-memory report

* chore: update snapshots
  • Loading branch information
elsapet authored Sep 19, 2023
1 parent 2a567ad commit 4f9beb1
Show file tree
Hide file tree
Showing 70 changed files with 7,909 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=6) "schema",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=12) "datatypes.cs",
Expand Down Expand Up @@ -30,6 +31,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=6) "schema",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=12) "datatypes.cs",
Expand Down Expand Up @@ -58,6 +60,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=6) "schema",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=12) "datatypes.cs",
Expand Down Expand Up @@ -86,6 +89,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=6) "schema",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=12) "datatypes.cs",
Expand Down Expand Up @@ -114,6 +118,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=6) "schema",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=12) "datatypes.cs",
Expand Down Expand Up @@ -142,6 +147,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=6) "schema",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=12) "datatypes.cs",
Expand Down Expand Up @@ -170,6 +176,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=6) "schema",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=12) "datatypes.cs",
Expand Down
14 changes: 14 additions & 0 deletions internal/detectors/csharp/.snapshots/TestDetectorReportInterfaces
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=6) "schema",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=9) "config.cs",
Expand Down Expand Up @@ -30,6 +31,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=9) "interface",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=9) "config.cs",
Expand Down Expand Up @@ -61,6 +63,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=9) "interface",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=9) "config.cs",
Expand Down Expand Up @@ -92,6 +95,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=6) "schema",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=7) "urls.cs",
Expand Down Expand Up @@ -120,6 +124,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=6) "schema",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=7) "urls.cs",
Expand Down Expand Up @@ -148,6 +153,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=6) "schema",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=7) "urls.cs",
Expand Down Expand Up @@ -176,6 +182,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=9) "interface",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=7) "urls.cs",
Expand Down Expand Up @@ -204,6 +211,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=9) "interface",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=7) "urls.cs",
Expand Down Expand Up @@ -240,6 +248,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=9) "interface",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=7) "urls.cs",
Expand Down Expand Up @@ -272,6 +281,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=9) "interface",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=7) "urls.cs",
Expand Down Expand Up @@ -300,6 +310,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=9) "interface",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=7) "urls.cs",
Expand Down Expand Up @@ -328,6 +339,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=9) "interface",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=7) "urls.cs",
Expand Down Expand Up @@ -356,6 +368,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=9) "interface",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=7) "urls.cs",
Expand Down Expand Up @@ -384,6 +397,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=9) "interface",
DetectorType: (detectors.Type) (len=6) "csharp",
DetectorLanguage: (detectors.Language) "",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=7) "urls.cs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "gradleparser",
DetectorLanguage: (detectors.Language) (len=4) "Java",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=12) "build.gradle",
Expand All @@ -24,6 +25,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "gradleparser",
DetectorLanguage: (detectors.Language) (len=4) "Java",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=12) "build.gradle",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerjson",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.json",
Expand All @@ -24,6 +25,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerjson",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand All @@ -24,6 +25,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand All @@ -46,6 +48,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand All @@ -68,6 +71,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand All @@ -90,6 +94,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand All @@ -112,6 +117,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand All @@ -134,6 +140,7 @@
(*detections.Detection)({
Type: (detections.DetectionType) (len=10) "dependency",
DetectorType: (detectors.Type) (len=12) "composerlock",
DetectorLanguage: (detectors.Language) (len=3) "PHP",
CommitSHA: (string) "",
Source: (source.Source) {
Filename: (string) (len=13) "composer.lock",
Expand Down
31 changes: 18 additions & 13 deletions internal/detectors/dependencies/dependencies.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,24 @@ func discoverDependency(report report.Report, file *file.FileInfo, discover func
for _, dep := range result.Dependencies {
startColumnNumber := int(dep.Column)
lineNumber := int(dep.Line)
report.AddDependency(detectors.Type(result.Provider), dependencies.Dependency{
Group: dep.Group,
Name: dep.Name,
Version: dep.Version,
PackageManager: result.PackageManager,
}, source.Source{
Language: file.Language,
LanguageType: file.LanguageTypeString(),
Filename: file.RelativePath,
StartColumnNumber: &startColumnNumber,
StartLineNumber: &lineNumber,
EndLineNumber: &lineNumber,
})
report.AddDependency(
detectors.Type(result.Provider),
detectors.Language(result.Language),
dependencies.Dependency{
Group: dep.Group,
Name: dep.Name,
Version: dep.Version,
PackageManager: result.PackageManager,
},
source.Source{
Language: file.Language,
LanguageType: file.LanguageTypeString(),
Filename: file.RelativePath,
StartColumnNumber: &startColumnNumber,
StartLineNumber: &lineNumber,
EndLineNumber: &lineNumber,
},
)
}

return true, nil
Expand Down
Loading

0 comments on commit 4f9beb1

Please sign in to comment.