Skip to content

Commit a6c05cc

Browse files
Added support for comments and metrics in C# code (Fixes #59).
1 parent da1553b commit a6c05cc

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

gitinspector/comment.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding: utf-8
22
#
3-
# Copyright © 2012-2014 Ejwa Software. All rights reserved.
3+
# Copyright © 2012-2015 Ejwa Software. All rights reserved.
44
#
55
# This file is part of gitinspector.
66
#
@@ -19,17 +19,18 @@
1919

2020
from __future__ import unicode_literals
2121

22-
__comment_begining__ = {"java": "/*", "c": "/*", "cc": "/*", "cpp": "/*", "h": "/*", "hh": "/*", "hpp": "/*", "hs": "{-", "html": "<!--",
23-
"php": "/*", "py": "\"\"\"", "glsl": "/*", "rb": "=begin", "js": "/*", "jspx": "<!--", "scala": "/*",
24-
"sql": "/*", "tex": "\\begin{comment}", "xhtml": "<!--", "xml": "<!--", "ml": "(*", "mli": "(*" }
22+
__comment_begining__ = { "java": "/*", "c": "/*", "cc": "/*", "cpp": "/*", "cs": "/*", "h": "/*", "hh": "/*", "hpp": "/*",
23+
"hs": "{-", "html": "<!--", "php": "/*", "py": "\"\"\"", "glsl": "/*", "rb": "=begin", "js": "/*",
24+
"jspx": "<!--", "scala": "/*", "sql": "/*", "tex": "\\begin{comment}", "xhtml": "<!--",
25+
"xml": "<!--", "ml": "(*", "mli": "(*" }
2526

26-
__comment_end__ = {"java": "*/", "c": "*/", "cc": "*/", "cpp": "*/", "h": "*/", "hh": "*/", "hpp": "*/", "hs": "-}", "html": "-->",
27-
"php": "/*", "py": "\"\"\"", "glsl": "*/", "rb": "=end", "js": "*/", "jspx": "-->", "scala": "*/",
28-
"sql": "*/", "tex": "\\end{comment}", "xhtml": "-->", "xml": "-->", "ml": "*)", "mli": "*)" }
27+
__comment_end__ = { "java": "*/", "c": "*/", "cc": "*/", "cpp": "*/", "cs": "*/", "h": "*/", "hh": "*/", "hpp": "*/", "hs": "-}",
28+
"html": "-->", "php": "/*", "py": "\"\"\"", "glsl": "*/", "rb": "=end", "js": "*/", "jspx": "-->",
29+
"scala": "*/", "sql": "*/", "tex": "\\end{comment}", "xhtml": "-->", "xml": "-->", "ml": "*)", "mli": "*)" }
2930

30-
__comment__ = {"java": "//", "c": "//", "cc": "//", "cpp": "//", "h": "//", "hh": "//", "hpp": "//", "hs": "--", "pl": "#", "php": "//",
31-
"py": "#", "glsl": "//", "rb": "#", "js": "//", "scala": "//", "sql": "--", "tex": "%", "ada": "--", "ads": "--",
32-
"adb": "--", "pot": "#", "po": "#" }
31+
__comment__ = { "java": "//", "c": "//", "cc": "//", "cpp": "//", "cs": "//", "h": "//", "hh": "//", "hpp": "//", "hs": "--",
32+
"pl": "#", "php": "//", "py": "#", "glsl": "//", "rb": "#", "js": "//", "scala": "//", "sql": "--", "tex": "%",
33+
"ada": "--", "ads": "--", "adb": "--", "pot": "#", "po": "#" }
3334

3435
__comment_markers_must_be_at_begining__ = {"tex": True}
3536

gitinspector/metrics.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# coding: utf-8
22
#
3-
# Copyright © 2012-2014 Ejwa Software. All rights reserved.
3+
# Copyright © 2012-2015 Ejwa Software. All rights reserved.
44
#
55
# This file is part of gitinspector.
66
#
@@ -28,12 +28,15 @@
2828
import re
2929
import subprocess
3030

31-
__metric_eloc__ = {"java": 500, "c": 500, "cpp": 500, "h": 300, "hpp": 300, "php": 500, "py": 500, "glsl": 1000,
31+
__metric_eloc__ = {"java": 500, "c": 500, "cpp": 500, "cs": 500, "h": 300, "hpp": 300, "php": 500, "py": 500, "glsl": 1000,
3232
"rb": 500, "js": 500, "sql": 1000, "xml": 1000}
3333

3434
__metric_cc_tokens__ = [[["java", "js", "c", "cc", "cpp"], ["else", "for\s+\(.*\)", "if\s+\(.*\)", "case\s+\w+:",
3535
"default:", "while\s+\(.*\)"],
3636
["assert", "break", "continue", "return"]],
37+
[["cs"], ["else", "for\s+\(.*\)", "foreach\s+\(.*\)", "goto\s+\w+:", "if\s+\(.*\)", "case\s+\w+:",
38+
"default:", "while\s+\(.*\)"],
39+
["assert", "break", "continue", "return"]],
3740
[["py"], ["^\s+elif .*:$", "^\s+else:$", "^\s+for .*:", "^\s+if .*:$", "^\s+while .*:$"],
3841
["^\s+assert", "break", "continue", "return"]]]
3942

0 commit comments

Comments
 (0)