Skip to content

Commit

Permalink
Add PRQL (#69)
Browse files Browse the repository at this point in the history
* Add PRQL

* Update README.md

* Update analyzer_test.go

* Update scanner_test.go

* Update README.md

Co-authored-by: João Daniel Rufino <joaodaniel0405@gmail.com>

---------

Co-authored-by: João Daniel Rufino <joaodaniel0405@gmail.com>
  • Loading branch information
vanillajonathan and JoaoDanielRufino authored Oct 6, 2023
1 parent 8b12162 commit 09ccbee
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ $ gcloc languages
PowerShell | .ps1 | # |
Processing | .pde | // | /* */
Protocol Buffers | .proto | // |
PRQL | .prql | # |
Python | .py | # | """ """
R | .r .R | # |
Rego | .rego | # |
Expand Down
5 changes: 5 additions & 0 deletions internal/constants/languages.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ var Languages = language.Languages{
MultiLineComments: [][]string{{"\"\"\"", "\"\"\""}},
Extensions: []string{".py"},
},
"PRQL": {
LineComments: []string{"#"},
MultiLineComments: [][]string{},
Extensions: []string{".prql"},
},
"R": {
LineComments: []string{"#"},
MultiLineComments: [][]string{},
Expand Down
15 changes: 15 additions & 0 deletions pkg/analyzer/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ func TestMatchingFiles(t *testing.T) {
Extension: ".py",
Language: "Python",
},
{
FilePath: filepath.Join(codeSamplesDir, "example.prql"),
Extension: ".prql",
Language: "PRQL",
},
{
FilePath: filepath.Join(codeSamplesDir, "main.rb"),
Extension: ".rb",
Expand Down Expand Up @@ -189,6 +194,11 @@ func TestMatchingFiles(t *testing.T) {
Extension: ".py",
Language: "Python",
},
{
FilePath: filepath.Join(codeSamplesDir, "example.prql"),
Extension: ".prql",
Language: "PRQL",
},
{
FilePath: filepath.Join(codeSamplesDir, "main.rb"),
Extension: ".rb",
Expand Down Expand Up @@ -287,6 +297,11 @@ func TestMatchingFiles(t *testing.T) {
Extension: ".py",
Language: "Python",
},
{
FilePath: filepath.Join(codeSamplesDir, "example.prql"),
Extension: ".prql",
Language: "PRQL",
},
{
FilePath: filepath.Join(codeSamplesDir, "main.rb"),
Extension: ".rb",
Expand Down
12 changes: 12 additions & 0 deletions pkg/scanner/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ func TestScan(t *testing.T) {
Extension: ".txt",
Language: "Plain Text",
},
{
FilePath: filepath.Join(codeSamplesDir, "example.prql"),
Extension: ".prql",
Language: "PRQL",
},
}

expected := []scanResult{
Expand Down Expand Up @@ -242,6 +247,13 @@ func TestScan(t *testing.T) {
BlankLines: 13,
Comments: 0,
},
{
Metadata: files[18],
Lines: 5,
CodeLines: 4,
BlankLines: 0,
Comments: 1,
},
}

result, err := scanner.Scan(files)
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/code_samples/example.prql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This is a comment
from track_plays
filter plays > 10_000
sort length
take 10

0 comments on commit 09ccbee

Please sign in to comment.