Skip to content

Commit d5eecd4

Browse files
authored
Merge pull request #964 from josefs/master
Add support for CodeQL
2 parents 09372e1 + dddb989 commit d5eecd4

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,7 @@ ClojureScript (cljs)
11091109
CMake (cmake, cmake.in, CMakeLists.txt)
11101110
COBOL (CBL, cbl, ccp, COB, cob, cobol, cpy)
11111111
CoCoA 5 (c5, cocoa5, cocoa5server, cpkg5)
1112+
CodeQL (ql, qll)
11121113
CoffeeScript (_coffee, cakefile, cjsx, coffee, iced)
11131114
ColdFusion (cfm, cfml)
11141115
ColdFusion CFScript (cfc)

Unix/t/00_C.t

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ my @Tests = (
244244
'ref' => '../tests/outputs/Buchberger.cocoa5.yaml',
245245
'args' => '../tests/inputs/Buchberger.cocoa5',
246246
},
247+
{
248+
'name' => 'CodeQL',
249+
'ref' => '../tests/outputs/CodeQL.ql.yaml',
250+
'args' => '../tests/inputs/CodeQL.ql',
251+
},
247252
{
248253
'name' => 'ColdFusion',
249254
'ref' => '../tests/outputs/ColdFusion.cfm.yaml',

cloc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8950,6 +8950,8 @@ sub set_constants { # {{{1
89508950
'COB' => 'COBOL' ,
89518951
'cocoa5' => 'CoCoA 5' ,
89528952
'code-workspace' => 'VSCode Workspace' ,
8953+
'ql' => 'CodeQL' ,
8954+
'qll' => 'CodeQL' ,
89538955
'c5' => 'CoCoA 5' ,
89548956
'cpkg5' => 'CoCoA 5' ,
89558957
'cocoa5server'=> 'CoCoA 5' ,
@@ -10222,6 +10224,11 @@ sub set_constants { # {{{1
1022210224
[ 'remove_matches' , '^\s*--' ],
1022310225
[ 'remove_inline' , '--.*$' ],
1022410226
],
10227+
'CodeQL' => [
10228+
[ 'rm_comments_in_strings', '"', '/*', '*/' ],
10229+
[ 'rm_comments_in_strings', '"', '//', '' ],
10230+
[ 'call_regexp_common' , 'C++' ],
10231+
],
1022510232
'CoffeeScript' => [
1022610233
[ 'remove_matches' , '^\s*#' ],
1022710234
[ 'remove_inline' , '#.*$' ],
@@ -12050,6 +12057,7 @@ sub set_constants { # {{{1
1205012057
'CMake' => 1.00,
1205112058
'COBOL' => 1.04,
1205212059
'CoCoA 5' => 1.04,
12060+
'CodeQL' => 2.50,
1205312061
'CoffeeScript' => 2.00,
1205412062
'Constraint Grammar' => 4.00,
1205512063
'Containerfile' => 2.00,

tests/inputs/CodeQL.ql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @name Find unused variables
3+
* @description Finds local variables that are defined but never used.
4+
* @kind problem
5+
* @problem.severity warning
6+
*/
7+
8+
import javascript
9+
10+
// Find all variable declarations
11+
from Variable v, DeclStmt decl
12+
where
13+
decl.getADecl().getBindingPattern() = v.getADeclaration() and
14+
not exists(VarAccess access | access.getVariable() = v) and
15+
not v.getName().matches("\\_%")
16+
select v, "Variable '" + v.getName() + "' is declared but never used."

tests/outputs/CodeQL.ql.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
# github.com/AlDanial/cloc
3+
header :
4+
cloc_url : github.com/AlDanial/cloc
5+
cloc_version : 2.09
6+
elapsed_seconds : 0.00732088088989258
7+
n_files : 1
8+
n_lines : 16
9+
files_per_second : 136.595583924966
10+
lines_per_second : 2185.52934279945
11+
report_file : tests/outputs/CodeQL.ql.yaml
12+
'CodeQL' :
13+
nFiles: 1
14+
blank: 2
15+
comment: 7
16+
code: 7
17+
SUM:
18+
blank: 2
19+
comment: 7
20+
code: 7
21+
nFiles: 1

0 commit comments

Comments
 (0)