-
Notifications
You must be signed in to change notification settings - Fork 385
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
Tidy hash generation bugfixes #1114
Conversation
libcodechecker/util.py
Outdated
Return the given line from the file. If line_no is larger than the number | ||
of lines in the file then empty string returns. | ||
""" | ||
with open(file_name) as f: |
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.
Handling the file error exceptions would be nice here.
@@ -298,6 +300,18 @@ def _create_diag(message, fmap): | |||
diag['path'].append(PListConverter._create_event_from_note(message, | |||
fmap)) | |||
|
|||
hash_content = [os.path.basename(message.path), |
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 factor out the hash generation to one module and add comment why is it generated this way.
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.
Also, why did we add code to generate the hash? Didn't we already have such code? If that is not used shouldn't we delete that?
@bruntib Unit test cases are failed! |
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.
Shouldn't we have a test-case for this?
message.message, | ||
get_line(message.path, message.line), | ||
str(message.column), | ||
str(message.column)] |
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.
Is it intentional to include the column twice?
@@ -298,6 +300,18 @@ def _create_diag(message, fmap): | |||
diag['path'].append(PListConverter._create_event_from_note(message, | |||
fmap)) | |||
|
|||
hash_content = [os.path.basename(message.path), |
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.
Also, why did we add code to generate the hash? Didn't we already have such code? If that is not used shouldn't we delete that?
89b547b
to
ca8b7e0
Compare
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.
-Make sure that you create a ticket for the incorrect processing of report hashes in case the report hash is missing from the test file
libcodechecker/report.py
Outdated
@@ -84,7 +84,7 @@ def compare_ctrl_sections(curr, prev): | |||
from_col = m_loc.get('col') | |||
until_col = m_loc.get('col') | |||
|
|||
line_content = linecache.getline(source_file, source_line) | |||
line_content = get_line(source_file, source_line) | |||
|
|||
if line_content == '' and not os.path.isfile(source_file): | |||
LOG.debug("Failed to generate report hash.") |
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 should be an ERROR level log
@@ -11,6 +11,8 @@ | |||
<string>clang-analyzer-core.DivideZero</string> | |||
<key>description</key> | |||
<string>Division by zero</string> | |||
<key>issue_hash_content_of_line_in_context</key> | |||
<string>b650887dabcbf08d794479d8d9c652b1</string> |
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.
Fix this hash. This hash does not contain the source code line.
@@ -84,7 +84,7 @@ def compare_ctrl_sections(curr, prev): | |||
from_col = m_loc.get('col') | |||
until_col = m_loc.get('col') | |||
|
|||
line_content = linecache.getline(source_file, source_line) | |||
line_content = get_line(source_file, source_line) |
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.
If the hash is generated on the server side, because the original PLIST does not contain it, then the source_file will point to the path that is only valid on the client's machine.
Either fix this, or put here a fixme and create an issue
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.
Before the store do we overwrite the file paths in the plist files, to the directory where they are extracted, or the path changes are only done during the report processing and the actual plist files are not modified?
ca8b7e0
to
16e8724
Compare
@@ -9,12 +9,15 @@ | |||
""" | |||
|
|||
import copy | |||
import hashlib |
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.
Unused import.
import json | ||
import os | ||
import plistlib | ||
import re | ||
|
||
from libcodechecker.logger import LoggerFactory | ||
from libcodechecker.report import generate_report_hash | ||
from libcodechecker.util import get_line |
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.
Unused import
libcodechecker/util.py
Outdated
if line_no == 0: | ||
return line | ||
return '' | ||
except: |
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.
No exception type(s) specified. For more information see Codacy
.
16e8724
to
f650608
Compare
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.
LGTM!
On server side the linecache Python module cached the files from which it returned a given line. If the file changed and the file was queried from the cache then the given line returned from the old file version. In case of ClangTidy the bug hash is generated by CodeChecker. Because of the previous bug a false bug hash was generated if the line number of the bug event changed. So now the bug hash is computed on client side and is written to the .plist file. Server will use this hash instead of generating it again. When a bug path changed because it is shifted a few lines downer then the corresponding line number was only updated in BagPathEvent and BugReportPoint tables, but not in Report table. This caused a GUI glitch, i.e. it didn't jump to the correct position when a report was opened.
f650608
to
b7d908a
Compare
On server side the linecache Python module cached the files from which
it returned a given line. If the file changed and the file was queried
from the cache then the given line returned from the old file version.
In case of ClangTidy the bug hash is generated by CodeChecker. Because
of the previous bug a false bug hash was generated if the line number of
the bug event changed. So now the bug hash is computed on client side
and is written to the .plist file. Server will use this hash instead of
generating it again.
When a bug path changed because it is shifted a few lines downer then
the corresponding line number was only updated in BagPathEvent and
BugReportPoint tables, but not in Report table. This caused a GUI
glitch, i.e. it didn't jump to the correct position when a report was
opened.
Fixes #1106