Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 4cd3f89

Browse files
author
Sauyon Lee
authored
Merge pull request #168 from max-schaefer/make-autoformat
Add Make target to autoformat all QL.
2 parents 524b11b + 1342d86 commit 4cd3f89

6 files changed

Lines changed: 24 additions & 15 deletions

File tree

.github/workflows/codeqltest.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
echo "Done"
2121
cd $HOME
2222
echo "Downloading CodeQL CLI..."
23-
curl https://github.com/github/codeql-cli-binaries/releases/download/v2.1.1/codeql.zip -L -o codeql.zip
23+
curl https://github.com/github/codeql-cli-binaries/releases/download/v2.2.0/codeql.zip -L -o codeql.zip
2424
echo "Done"
2525
echo "Unpacking CodeQL CLI..."
2626
unzip -q codeql.zip
@@ -33,6 +33,9 @@ jobs:
3333
- name: Build
3434
run: env PATH=$PATH:$HOME/codeql make
3535

36+
- name: Check that all QL code is autoformatted
37+
run: env PATH=$PATH:$HOME/codeql make AUTOFORMAT=--check-only autoformat
38+
3639
- name: Test
3740
run: env PATH=$PATH:$HOME/codeql make test
3841

@@ -53,7 +56,7 @@ jobs:
5356
echo "Done"
5457
cd $HOME
5558
echo "Downloading CodeQL CLI..."
56-
curl https://github.com/github/codeql-cli-binaries/releases/download/v2.1.1/codeql.zip -L -o codeql.zip
59+
curl https://github.com/github/codeql-cli-binaries/releases/download/v2.2.0/codeql.zip -L -o codeql.zip
5760
echo "Done"
5861
echo "Unpacking CodeQL CLI..."
5962
unzip -q codeql.zip
@@ -86,7 +89,7 @@ jobs:
8689
echo "Done"
8790
cd "$HOME"
8891
echo "Downloading CodeQL CLI..."
89-
Invoke-WebRequest -Uri https://github.com/github/codeql-cli-binaries/releases/download/v2.1.1/codeql.zip -OutFile codeql.zip
92+
Invoke-WebRequest -Uri https://github.com/github/codeql-cli-binaries/releases/download/v2.2.0/codeql.zip -OutFile codeql.zip
9093
echo "Done"
9194
echo "Unpacking CodeQL CLI..."
9295
Expand-Archive codeql.zip -DestinationPath $HOME

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@ EXTRACTOR_PACK_OUT = build/codeql-extractor-go
2020

2121
BINARIES = go-extractor go-tokenizer go-autobuilder go-bootstrap go-gen-dbscheme
2222

23-
.PHONY: tools tools-codeql tools-codeql-full clean \
23+
.PHONY: tools tools-codeql tools-codeql-full clean autoformat \
2424
tools-linux64 tools-osx64 tools-win64
2525

2626
clean:
2727
rm -rf tools/bin tools/linux64 tools/osx64 tools/win64 tools/net tools/opencsv
2828
rm -rf $(EXTRACTOR_PACK_OUT) build/stats build/testdb
2929

30+
AUTOFORMAT=-qq -i
31+
32+
autoformat:
33+
find ql/src -name *.ql -or -name *.qll | xargs codeql query format $(AUTOFORMAT)
34+
3035
tools: $(addsuffix $(EXE),$(addprefix tools/bin/,$(BINARIES))) tools/tokenizer.jar
3136

3237
.PHONY: $(addsuffix $(EXE),$(addprefix tools/bin/,$(BINARIES)))

ql/src/semmle/go/Comments.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Comment extends @comment, AstNode {
4242
* // a line comment
4343
* /* a block
4444
* comment *&#47
45-
*
45+
*
4646
* /* a block
4747
* comment *&#47
4848
* /* another block comment *&#47
@@ -71,7 +71,7 @@ class CommentGroup extends @comment_group, AstNode {
7171
* ```go
7272
* // function documentation
7373
* func double(x int) int { return 2 * x }
74-
*
74+
*
7575
* // generic declaration documentation
7676
* const (
7777
* // specifier documentation
@@ -93,7 +93,7 @@ class Documentable extends AstNode, @documentable {
9393
* ```go
9494
* // function documentation
9595
* func double(x int) int { return 2 * x }
96-
*
96+
*
9797
* // generic declaration documentation
9898
* const (
9999
* // specifier documentation

ql/src/semmle/go/Expr.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,7 +1559,7 @@ class SimpleName extends Name, Ident { }
15591559
* ```go
15601560
* fmt.Println
15611561
* ```
1562-
*/
1562+
*/
15631563
class QualifiedName extends Name, SelectorExpr { }
15641564

15651565
/**
@@ -1769,7 +1769,7 @@ private predicate isTypeExprTopDown(Expr e) {
17691769
*
17701770
* ```go
17711771
* int
1772-
* func
1772+
* func
17731773
* ```
17741774
*/
17751775
class TypeExpr extends Expr {

ql/src/semmle/go/Stmt.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -832,17 +832,17 @@ class TypeSwitchStmt extends @typeswitchstmt, SwitchStmt {
832832
* ```go
833833
* case i1 = <-c1:
834834
* print("received ", i1, " from c1\n")
835-
*
835+
*
836836
* case c2 <- i2:
837837
* print("sent ", i2, " to c2\n")
838-
*
838+
*
839839
* case i3, ok := (<-c3): // same as: i3, ok := <-c3
840840
* if ok {
841841
* print("received ", i3, " from c3\n")
842842
* } else {
843843
* print("c3 is closed\n")
844844
* }
845-
*
845+
*
846846
* default:
847847
* print("no communication\n")
848848
* ```
@@ -961,7 +961,7 @@ class SelectStmt extends @selectstmt, Stmt {
961961
* for a < b {
962962
* a *= 2
963963
* }
964-
*
964+
*
965965
* for i := 0; i < 10; i++ {
966966
* f(i)
967967
* }
@@ -985,7 +985,7 @@ class LoopStmt extends @loopstmt, Stmt, ScopeNode {
985985
* for a < b {
986986
* a *= 2
987987
* }
988-
*
988+
*
989989
* for i := 0; i < 10; i++ {
990990
* f(i)
991991
* }

ql/src/semmle/go/dataflow/internal/DataFlowUtil.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ class CallNode extends ExprNode {
330330
/**
331331
* Gets the data-flow node corresponding to the `i`th result of this call.
332332
*
333-
* If there is a single result then it is considered to be the 0th result. */
333+
* If there is a single result then it is considered to be the 0th result.
334+
*/
334335
Node getResult(int i) {
335336
i = 0 and result = getResult()
336337
or

0 commit comments

Comments
 (0)