-
Notifications
You must be signed in to change notification settings - Fork 581
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
CLOCBear: Add CLOCBear #1691
base: master
Are you sure you want to change the base?
CLOCBear: Add CLOCBear #1691
Conversation
tests/general/CLOCBearTest.py
Outdated
@@ -0,0 +1,93 @@ | |||
import unittest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file contains unused source code.
PyUnusedCodeBear, severity NORMAL, section flakes
.
The issue can be fixed by applying the following patch:
--- a/tests/general/CLOCBearTest.py
+++ b/tests/general/CLOCBearTest.py
@@ -1,4 +1,3 @@
-import unittest
import os
from queue import Queue
tests/general/CLOCBearTest.py
Outdated
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total), | ||
"Comment lines: {0}({1:.2f}%)".format(comment, comment * 100. / total), | ||
"Blank lines: {0}({1:.2f}%)".format(blank, blank * 100. / total), | ||
"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not use the preferred quotation marks.
QuotesBear, severity NORMAL, section python
.
The issue can be fixed by applying the following patch:
--- a/tests/general/CLOCBearTest.py
+++ b/tests/general/CLOCBearTest.py
@@ -43,7 +43,7 @@
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total),
"Comment lines: {0}({1:.2f}%)".format(comment, comment * 100. / total),
"Blank lines: {0}({1:.2f}%)".format(blank, blank * 100. / total),
- ""
+ ''
])
return((str)(message))
tests/general/CLOCBearTest.py
Outdated
"Total lines: {0}".format(total), | ||
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total), | ||
"Comment lines: {0}({1:.2f}%)".format(comment, comment * 100. / total), | ||
"Blank lines: {0}({1:.2f}%)".format(blank, blank * 100. / total), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not use the preferred quotation marks.
QuotesBear, severity NORMAL, section python
.
The issue can be fixed by applying the following patch:
--- a/tests/general/CLOCBearTest.py
+++ b/tests/general/CLOCBearTest.py
@@ -42,7 +42,7 @@
"Total lines: {0}".format(total),
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total),
"Comment lines: {0}({1:.2f}%)".format(comment, comment * 100. / total),
- "Blank lines: {0}({1:.2f}%)".format(blank, blank * 100. / total),
+ 'Blank lines: {0}({1:.2f}%)'.format(blank, blank * 100. / total),
""
])
return((str)(message))
tests/general/CLOCBearTest.py
Outdated
"Total files: {0}".format(nfiles), | ||
"Total lines: {0}".format(total), | ||
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total), | ||
"Comment lines: {0}({1:.2f}%)".format(comment, comment * 100. / total), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not use the preferred quotation marks.
QuotesBear, severity NORMAL, section python
.
The issue can be fixed by applying the following patch:
--- a/tests/general/CLOCBearTest.py
+++ b/tests/general/CLOCBearTest.py
@@ -41,7 +41,7 @@
"Total files: {0}".format(nfiles),
"Total lines: {0}".format(total),
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total),
- "Comment lines: {0}({1:.2f}%)".format(comment, comment * 100. / total),
+ 'Comment lines: {0}({1:.2f}%)'.format(comment, comment * 100. / total),
"Blank lines: {0}({1:.2f}%)".format(blank, blank * 100. / total),
""
])
tests/general/CLOCBearTest.py
Outdated
message = "\n".join(["Language: {0}".format(lang), | ||
"Total files: {0}".format(nfiles), | ||
"Total lines: {0}".format(total), | ||
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not use the preferred quotation marks.
QuotesBear, severity NORMAL, section python
.
The issue can be fixed by applying the following patch:
--- a/tests/general/CLOCBearTest.py
+++ b/tests/general/CLOCBearTest.py
@@ -40,7 +40,7 @@
message = "\n".join(["Language: {0}".format(lang),
"Total files: {0}".format(nfiles),
"Total lines: {0}".format(total),
- "Code lines: {0}({1:.2f}%)".format(code, code * 100. / total),
+ 'Code lines: {0}({1:.2f}%)'.format(code, code * 100. / total),
"Comment lines: {0}({1:.2f}%)".format(comment, comment * 100. / total),
"Blank lines: {0}({1:.2f}%)".format(blank, blank * 100. / total),
""
tests/general/CLOCBearTest.py
Outdated
total = code + comment + blank | ||
message = "\n".join(["Language: {0}".format(lang), | ||
"Total files: {0}".format(nfiles), | ||
"Total lines: {0}".format(total), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not use the preferred quotation marks.
QuotesBear, severity NORMAL, section python
.
The issue can be fixed by applying the following patch:
--- a/tests/general/CLOCBearTest.py
+++ b/tests/general/CLOCBearTest.py
@@ -39,7 +39,7 @@
total = code + comment + blank
message = "\n".join(["Language: {0}".format(lang),
"Total files: {0}".format(nfiles),
- "Total lines: {0}".format(total),
+ 'Total lines: {0}'.format(total),
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total),
"Comment lines: {0}({1:.2f}%)".format(comment, comment * 100. / total),
"Blank lines: {0}({1:.2f}%)".format(blank, blank * 100. / total),
tests/general/CLOCBearTest.py
Outdated
blank = result['BLANK'] | ||
total = code + comment + blank | ||
message = "\n".join(["Language: {0}".format(lang), | ||
"Total files: {0}".format(nfiles), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not use the preferred quotation marks.
QuotesBear, severity NORMAL, section python
.
The issue can be fixed by applying the following patch:
--- a/tests/general/CLOCBearTest.py
+++ b/tests/general/CLOCBearTest.py
@@ -38,7 +38,7 @@
blank = result['BLANK']
total = code + comment + blank
message = "\n".join(["Language: {0}".format(lang),
- "Total files: {0}".format(nfiles),
+ 'Total files: {0}'.format(nfiles),
"Total lines: {0}".format(total),
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total),
"Comment lines: {0}({1:.2f}%)".format(comment, comment * 100. / total),
tests/general/CLOCBearTest.py
Outdated
comment = result['COMMENTS'] | ||
blank = result['BLANK'] | ||
total = code + comment + blank | ||
message = "\n".join(["Language: {0}".format(lang), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not use the preferred quotation marks.
QuotesBear, severity NORMAL, section python
.
The issue can be fixed by applying the following patch:
--- a/tests/general/CLOCBearTest.py
+++ b/tests/general/CLOCBearTest.py
@@ -37,7 +37,7 @@
comment = result['COMMENTS']
blank = result['BLANK']
total = code + comment + blank
- message = "\n".join(["Language: {0}".format(lang),
+ message = "\n".join(['Language: {0}'.format(lang),
"Total files: {0}".format(nfiles),
"Total lines: {0}".format(total),
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total),
tests/general/CLOCBearTest.py
Outdated
comment = result['COMMENTS'] | ||
blank = result['BLANK'] | ||
total = code + comment + blank | ||
message = "\n".join(["Language: {0}".format(lang), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not use the preferred quotation marks.
QuotesBear, severity NORMAL, section python
.
The issue can be fixed by applying the following patch:
--- a/tests/general/CLOCBearTest.py
+++ b/tests/general/CLOCBearTest.py
@@ -37,7 +37,7 @@
comment = result['COMMENTS']
blank = result['BLANK']
total = code + comment + blank
- message = "\n".join(["Language: {0}".format(lang),
+ message = '\n'.join(["Language: {0}".format(lang),
"Total files: {0}".format(nfiles),
"Total lines: {0}".format(total),
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total),
tests/general/CLOCBearTest.py
Outdated
# self.uut, | ||
# file_contents, | ||
# [], | ||
# filename=get_testfile_path('apache_license_without_copyright.py'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is longer than allowed. (80 > 79)
LineLengthBear, severity NORMAL, section linelength
.
tests/general/CLOCBearTest.py
Outdated
"Total lines: {0}".format(total), | ||
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total), | ||
"Comment lines: {0}({1:.2f}%)".format(comment, comment * 100. / total), | ||
"Blank lines: {0}({1:.2f}%)".format(blank, blank * 100. / total), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is longer than allowed. (94 > 79)
LineLengthBear, severity NORMAL, section linelength
.
tests/general/CLOCBearTest.py
Outdated
"Total files: {0}".format(nfiles), | ||
"Total lines: {0}".format(total), | ||
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total), | ||
"Comment lines: {0}({1:.2f}%)".format(comment, comment * 100. / total), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is longer than allowed. (100 > 79)
LineLengthBear, severity NORMAL, section linelength
.
tests/general/CLOCBearTest.py
Outdated
message = "\n".join(["Language: {0}".format(lang), | ||
"Total files: {0}".format(nfiles), | ||
"Total lines: {0}".format(total), | ||
"Code lines: {0}({1:.2f}%)".format(code, code * 100. / total), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is longer than allowed. (91 > 79)
LineLengthBear, severity NORMAL, section linelength
.
tests/general/CLOCBearTest.py
Outdated
self.message_format = 'd' | ||
self.expected_results = {self.test_files[0] : {'LANGUAGE': 'C++', 'FILES': 1, 'CODE': 6, 'COMMENTS': 5, 'BLANK': 3}, | ||
self.test_files[1] : {'LANGUAGE': 'Python', 'FILES': 1, 'CODE': 3, 'COMMENTS': 2, 'BLANK': 3}, | ||
self.test_files[2] : {'LANGUAGE': 'C++', 'FILES': 1, 'CODE': 10, 'COMMENTS': 0, 'BLANK': 3} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is longer than allowed. (124 > 79)
LineLengthBear, severity NORMAL, section linelength
.
tests/general/CLOCBearTest.py
Outdated
self.test_files = ['example1.cpp', 'example2.py', 'example3.cpp'] | ||
self.message_format = 'd' | ||
self.expected_results = {self.test_files[0] : {'LANGUAGE': 'C++', 'FILES': 1, 'CODE': 6, 'COMMENTS': 5, 'BLANK': 3}, | ||
self.test_files[1] : {'LANGUAGE': 'Python', 'FILES': 1, 'CODE': 3, 'COMMENTS': 2, 'BLANK': 3}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is longer than allowed. (127 > 79)
LineLengthBear, severity NORMAL, section linelength
.
tests/general/CLOCBearTest.py
Outdated
self.uut = CLOCBear(Section('name'), Queue()) | ||
self.test_files = ['example1.cpp', 'example2.py', 'example3.cpp'] | ||
self.message_format = 'd' | ||
self.expected_results = {self.test_files[0] : {'LANGUAGE': 'C++', 'FILES': 1, 'CODE': 6, 'COMMENTS': 5, 'BLANK': 3}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is longer than allowed. (124 > 79)
LineLengthBear, severity NORMAL, section linelength
.
bears/general/CLOCBear.py
Outdated
code = (int)(match.group(5)) | ||
total = blank + comment + code | ||
report = 'Language: {0}\nTotal files: {1}\nTotal lines: {2}\nCode lines: {3}({4:.2f}%)\nComment lines: {5}({6:.2f}%)\nBlank lines: {7}({8:.2f}%)\n'\ | ||
.format(lang, nfiles, total, code, code*100./total, comment, comment*100./total, blank, blank*100./total) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is longer than allowed. (130 > 79)
LineLengthBear, severity NORMAL, section linelength
.
bears/general/CLOCBear.py
Outdated
comment = (int)(match.group(4)) | ||
code = (int)(match.group(5)) | ||
total = blank + comment + code | ||
report = 'Language: {0}\nTotal files: {1}\nTotal lines: {2}\nCode lines: {3}({4:.2f}%)\nComment lines: {5}({6:.2f}%)\nBlank lines: {7}({8:.2f}%)\n'\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is longer than allowed. (164 > 79)
LineLengthBear, severity NORMAL, section linelength
.
bears/general/CLOCBear.py
Outdated
files = (int)(re.search(r'(\d+)', lines[1]).group(1)) | ||
ignored_files = (int)(re.search(r'(\d+)', lines[2]).group(1)) | ||
if(files == ignored_files): | ||
msg = 'No valid files. File should belong to valid programming language.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is longer than allowed. (85 > 79)
LineLengthBear, severity NORMAL, section linelength
.
second = 10 # Second number | ||
|
||
sum = first + second | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
W391 blank line at end of file'
PycodestyleBear (W391), severity NORMAL, section autopep8
.
# This program will just try to add two static numbers | ||
|
||
first = 5 # First number | ||
second = 10 # Second number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E261 at least two spaces before inline comment'
PycodestyleBear (E261), severity NORMAL, section autopep8
.
# This comments are for testing purpose | ||
# This program will just try to add two static numbers | ||
|
||
first = 5 # First number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E261 at least two spaces before inline comment'
PycodestyleBear (E261), severity NORMAL, section autopep8
.
second = 10 # Second number | ||
|
||
sum = first + second | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code does not comply to PEP8.
PEP8Bear, severity NORMAL, section autopep8
.
The issue can be fixed by applying the following patch:
--- a/tests/general/cloc_test_files/example2.py
+++ b/tests/general/cloc_test_files/example2.py
@@ -5,4 +5,3 @@
second = 10 # Second number
sum = first + second
-
# This comments are for testing purpose | ||
# This program will just try to add two static numbers | ||
|
||
first = 5 # First number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code does not comply to PEP8.
PEP8Bear, severity NORMAL, section autopep8
.
The issue can be fixed by applying the following patch:
--- a/tests/general/cloc_test_files/example2.py
+++ b/tests/general/cloc_test_files/example2.py
@@ -1,8 +1,8 @@
# This comments are for testing purpose
# This program will just try to add two static numbers
-first = 5 # First number
-second = 10 # Second number
+first = 5 # First number
+second = 10 # Second number
sum = first + second
bears/general/CLOCBear.py
Outdated
.format(lang, nfiles, total, code, code*100./total, comment, comment*100./total, blank, blank*100./total) | ||
yield Result.from_values(origin = self, | ||
message = report, | ||
file = filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E251 unexpected spaces around keyword / parameter equals'
PycodestyleBear (E251), severity NORMAL, section autopep8
.
bears/general/CLOCBear.py
Outdated
.format(lang, nfiles, total, code, code*100./total, comment, comment*100./total, blank, blank*100./total) | ||
yield Result.from_values(origin = self, | ||
message = report, | ||
file = filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E251 unexpected spaces around keyword / parameter equals'
PycodestyleBear (E251), severity NORMAL, section autopep8
.
bears/general/CLOCBear.py
Outdated
report = 'Language: {0}\nTotal files: {1}\nTotal lines: {2}\nCode lines: {3}({4:.2f}%)\nComment lines: {5}({6:.2f}%)\nBlank lines: {7}({8:.2f}%)\n'\ | ||
.format(lang, nfiles, total, code, code*100./total, comment, comment*100./total, blank, blank*100./total) | ||
yield Result.from_values(origin = self, | ||
message = report, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E251 unexpected spaces around keyword / parameter equals'
PycodestyleBear (E251), severity NORMAL, section autopep8
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run coala locally to get rid of the gitmate errors !
Thanks for getting the bear working. We now face a design problem to accommodate this bear. Can you come onto gitter, and ping @sils and I. |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
1 similar comment
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
This bear gives statistics about number of lines, number of comment lines, and total number of lines. Closes coala#1577
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
2 similar comments
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is a global bear, we need a test which shows how it works when given multiple files.
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
1 similar comment
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
This bear gives statistics about number of lines,
number of comment lines, and total number of lines.
Closes #1577
For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!
Checklist
them.
individually. It is not sufficient to have "fixup commits" on your PR,
our bot will still report the issues for the previous commit.) You will
likely receive a lot of bot comments and build failures if coala does not
pass on every single commit!
After you submit your pull request, DO NOT click the 'Update Branch' button.
When asked for a rebase, consult coala.io/rebase
instead.
Please consider helping us by reviewing other peoples pull requests as well:
cobot mark wip <URL>
to get it outof the review queue.
The more you review, the more your score will grow at coala.io and we will
review your PRs faster!