Skip to content

ci: Fix tests #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Eask
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"1.0.0"
"Plugin shows complexity information")

(website-url "https://github.com/abougouffa/cognitive-complexity")
(website-url "https://github.com/emacs-vs/cognitive-complexity")
(keywords "convenience" "complexity")

(package-file "cognitive-complexity.el")
Expand All @@ -18,5 +18,11 @@

(development
(depends-on "kotlin-mode")
(depends-on "go-mode")
(depends-on "lua-mode")
(depends-on "rust-mode")
(depends-on "typescript-mode")
(depends-on "treesit-langs"
:repo "emacs-tree-sitter/treesit-langs"
:fetcher 'github) ; pre-built binary
(depends-on "treesit-auto"))
2 changes: 1 addition & 1 deletion cognitive-complexity.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
;; Author: Abdelhak BOUGOUFFA
;; Maintainer: Shen, Jen-Chieh
;; Maintainer: Abdelhak BOUGOUFFA
;; URL: https://github.com/abougouffa/cognitive-complexity
;; URL: https://github.com/emacs-vs/cognitive-complexity
;; Version: 1.0.0
;; Package-Requires: ((emacs "29.1"))
;; Keywords: convenience tools c languages
Expand Down
43 changes: 22 additions & 21 deletions test/bash-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,36 @@
;;

;;; Code:

(require 'cognitive-complexity)

(cognitive-complexity-test bash-simple
"test/bash/Simple.sh"
bash-ts-mode
sh-mode
'(3
(function_definition . 0)
(command . 0)
(function_definition . 0)
(for_statement . 1)
(command . 0)
(command . 0)
(function_definition . 0)
(while_statement . 1)
(command . 0)
(if_statement . 1)
(command . 0)
(command . 0)
(command . 0)))
("function_definition" . 0)
("command" . 0)
("function_definition" . 0)
("for_statement" . 1)
("command" . 0)
("command" . 0)
("function_definition" . 0)
("while_statement" . 1)
("command" . 0)
("if_statement" . 1)
("command" . 0)
("command" . 0)
("command" . 0)))

(cognitive-complexity-test bash-recursion
"test/bash/Recursion.sh"
bash-ts-mode
sh-mode
'(2
(function_definition . 0)
(if_statement . 1)
(command . 0)
(command . 1)
(command . 0)
(command . 0)))
("function_definition" . 0)
("if_statement" . 1)
("command" . 0)
("command" . 1)
("command" . 0)
("command" . 0)))

;;; bash-test.el ends here
81 changes: 41 additions & 40 deletions test/c-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,69 +21,70 @@
;;

;;; Code:

(require 'cognitive-complexity)

(cognitive-complexity-test c-simple
"test/c/Simple.c"
c-ts-mode
c-mode
'(4
(preproc_ifdef . 1)
(function_definition . 0)
(for_statement . 1)
(while_statement . 1)
(if_statement . 1)
(call_expression . 0)))
("preproc_ifdef" . 1)
("function_definition" . 0)
("for_statement" . 1)
("while_statement" . 1)
("if_statement" . 1)
("call_expression" . 0)))

(cognitive-complexity-test c-recursion
"test/c/Recursion.c"
c-ts-mode
c-mode
'(2
(function_definition . 0)
(if_statement . 1)
(call_expression . 1)))
("function_definition" . 0)
("if_statement" . 1)
("call_expression" . 1)))

(cognitive-complexity-test c-control-flow
"test/c/ControlFlow.c"
c-ts-mode
c-mode
'(5
(function_definition . 0)
(switch_statement . 1)
(call_expression . 0)
(function_definition . 0)
(do_statement . 1)
(call_expression . 0)
(function_definition . 0)
(call_expression . 0)
(if_statement . 1)
(goto_statement . 2)))
("function_definition" . 0)
("switch_statement" . 1)
("call_expression" . 0)
("function_definition" . 0)
("do_statement" . 1)
("call_expression" . 0)
("function_definition" . 0)
("call_expression" . 0)
("if_statement" . 1)
("goto_statement" . 2)))

(cognitive-complexity-test c-logical-operators
"test/c/LogicalOperators.c"
c-ts-mode
c-mode
'(6
(function_definition . 0)
(if_statement . 1)
("&&" . 0)
(if_statement . 1)
("||" . 0)
(if_statement . 1)
("&&" . 0)
("||" . 1)
(if_statement . 1)
("||" . 1)
("&&" . 0)))
("function_definition" . 0)
("if_statement" . 1)
("&&" . 0)
("if_statement" . 1)
("||" . 0)
("if_statement" . 1)
("&&" . 0)
("||" . 1)
("if_statement" . 1)
("||" . 1)
("&&" . 0)))

;; Loosely inspired by go nested prints issue
;; (for verifying issue with multiple nested ifs inside a for-loop)
(cognitive-complexity-test c-nested-prints
"test/c/NestedPrints.c"
c-ts-mode
c-mode
'(5
(function_definition . 0)
(for_statement . 1)
(if_statement . 2)
(call_expression . 0)
(if_statement . 2)
(call_expression . 0)))
(for_statement . 1)
(if_statement . 2)
(call_expression . 0)
(if_statement . 2)
(call_expression . 0)))

;;; c-test.el ends here
28 changes: 14 additions & 14 deletions test/go-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,33 @@

(cognitive-complexity-test simple-go-code
"test/go/Simple.go"
go-ts-mode
go-mode
'(2
("function_declaration" . 0)
("if_statement" . 1)
("call_expression" . 0)
("for_statement" . 1)))
("if_statement" . 1)
("call_expression" . 0)
("for_statement" . 1)))

(cognitive-complexity-test recursion-go-code
"test/go/Recursion.go"
go-ts-mode
go-mode
'(2
("function_declaration" . 0)
("if_statement" . 1)
("call_expression" . 1)))
("if_statement" . 1)
("call_expression" . 1)))

;; Test of issue:
;; https://github.com/emacs-vs/codemetrics/issues/7
(cognitive-complexity-test go-nested-print-calls
"test/go/NestedPrints.go"
go-ts-mode
go-mode
'(6
("function_declaration" . 0)
("for_statement" . 1)
("if_statement" . 2)
("call_expression" . 0)
("if_statement" . 2)
("call_expression" . 0)
("for_statement" . 1)))
("for_statement" . 1)
("if_statement" . 2)
("call_expression" . 0)
("if_statement" . 2)
("call_expression" . 0)
("for_statement" . 1)))

;;; go-test.el ends here
9 changes: 5 additions & 4 deletions test/java-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@
;;

;;; Code:

(require 'cognitive-complexity)

(cognitive-complexity-test java-recursion
"test/java/Recursion.java"
java-mode
'(2
(class_declaration . 0)
(method_declaration . 0)
(if_statement . 1)
(method_invocation . 1)))
("class_declaration" . 0)
("method_declaration" . 0)
("if_statement" . 1)
("method_invocation" . 1)))

;;; java-test.el ends here
43 changes: 22 additions & 21 deletions test/javascript-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,44 @@
;;

;;; Code:

(require 'cognitive-complexity)

(cognitive-complexity-test javascript-simple
"test/javascript/Simple.js"
js-ts-mode
js-mode
'(3
(function_declaration . 0)
(call_expression . 0)
(call_expression . 0)
(for_statement . 1)
(if_statement . 2)))
("function_declaration" . 0)
("call_expression" . 0)
("call_expression" . 0)
("for_statement" . 1)
("if_statement" . 2)))

(cognitive-complexity-test javascript-recursion
"test/javascript/Recursion.js"
js-ts-mode
js-mode
'(2
(function_declaration . 0)
(if_statement . 1)
(call_expression . 1)))
("function_declaration" . 0)
("if_statement" . 1)
("call_expression" . 1)))

(cognitive-complexity-test javascript-nesting
"test/javascript/Nesting.js"
js-ts-mode
js-mode
'(4
(call_expression . 0)
(arrow_function . 0)
(call_expression . 0)
(call_expression . 0)
(function_expression . 0)
(if_statement . 2)
(arrow_function . 0)
(if_statement . 2)
(call_expression . 0)))
("call_expression" . 0)
("arrow_function" . 0)
("call_expression" . 0)
("call_expression" . 0)
("function_expression" . 0)
("if_statement" . 2)
("arrow_function" . 0)
("if_statement" . 2)
("call_expression" . 0)))

(cognitive-complexity-test javascript-logical-operators
"test/javascript/LogicalOperators.js"
js-ts-mode
js-mode
'(2
("&&" . 0)
("||" . 0)
Expand Down
31 changes: 16 additions & 15 deletions test/kotlin-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,38 @@
;;

;;; Code:

(require 'cognitive-complexity)
(require 'kotlin-mode)

(cognitive-complexity-test simple-kotlin-code
"test/kotlin/Simple.kt"
kotlin-mode
'(2
(function_declaration . 0)
(if_expression . 1)
(for_statement . 1)
(call_expression . 0)))
("function_declaration" . 0)
("if_expression" . 1)
("for_statement" . 1)
("call_expression" . 0)))

(cognitive-complexity-test kotlin-recursion
"test/kotlin/Recursion.kt"
kotlin-mode
'(2
(function_declaration . 0)
(if_expression . 1)
(call_expression . 1)))
("function_declaration" . 0)
("if_expression" . 1)
("call_expression" . 1)))

(cognitive-complexity-test kotlin-break-continue
"test/kotlin/BreakContinue.kt"
kotlin-mode
'(6
(function_declaration . 0)
(call_expression . 0)
(for_statement . 1)
(if_expression . 2)
("break" . 0)
(for_statement . 1)
(if_expression . 2)
("continue" . 0)))
("function_declaration" . 0)
("call_expression" . 0)
("for_statement" . 1)
("if_expression" . 2)
("break" . 0)
("for_statement" . 1)
("if_expression" . 2)
("continue" . 0)))

;;; kotlin-test.el ends here
Loading
Loading