Skip to content
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

Detection status #724

Merged
merged 2 commits into from
Aug 18, 2017
Merged

Detection status #724

merged 2 commits into from
Aug 18, 2017

Conversation

bruntib
Copy link
Contributor

@bruntib bruntib commented Jul 13, 2017

#709 should be merged first!

def handle_results(self, client=None):
return report_ids

def handle_results(self, client):
"""
Send the plist content to the database.
Server API calls should be used in one connection.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same one connection thing pointed out by @dkrupp earlier is here. We should clarify this, somehow.

detection_status = Column(Enum('new',
'unresolved',
'resolved',
'reopened'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So after all, should we keep the reopened status?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we keep reopened. Moreover in the latest implementation a report stays reopened unit it becomes resolved again.



def consumed_results(client, run_id):
def markFixed(l):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Let's keep not introducing style warnings and keep to the Pythonic nomenclature, mark_fixed. Also comment below is not a full sentence. I'm Vice Xazax now! 😛 )

//--- Details ---//

this.addChild(new Button({
label : 'Details',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this is that ugly window of #566. Good riddance, I think. I'm okay with losing this information, didn't seem too useful in the first place. If analysing a file failed, where could have the user click Details to find the failure output and such in the first place?

i['workspace']) ==
os.path.abspath(
args.config_directory))):
args.stop and not (i['port'] == args.view_port and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not relevant.

Doxyfile.in Outdated
@@ -34,7 +34,7 @@ PROJECT_NAME = "CodeChecker"
# This could be handy for archiving the generated documentation or
# if some version control system is used.

PROJECT_NUMBER = 5.9.1
PROJECT_NUMBER = 6.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not relevant.

@whisperity whisperity self-requested a review July 21, 2017 15:03
@bruntib bruntib force-pushed the detection_status branch 4 times, most recently from 84b58f9 to a46ae01 Compare July 23, 2017 16:02
@bruntib bruntib removed the WIP 💣 Work In Progress label Jul 23, 2017
@bruntib bruntib force-pushed the detection_status branch 2 times, most recently from bf31491 to 613897c Compare July 23, 2017 21:38
@dkrupp dkrupp modified the milestones: 6.0 pre1 , 6.0 pre2 Jul 25, 2017
@whisperity whisperity force-pushed the version6 branch 2 times, most recently from d47cf59 to 6c167b7 Compare July 27, 2017 12:47
Copy link
Contributor

@whisperity whisperity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase the topic branch, a lot of commits already in Ericsson/version6 are duplicated.

@whisperity whisperity added the WIP 💣 Work In Progress label Aug 3, 2017
@bruntib bruntib force-pushed the detection_status branch 2 times, most recently from 6be5d63 to 3f576c0 Compare August 11, 2017 13:31
@bruntib bruntib requested a review from Xazax-hun August 11, 2017 13:32
@bruntib bruntib force-pushed the detection_status branch 3 times, most recently from 1ca8382 to c78983a Compare August 16, 2017 13:08
@@ -50,6 +50,10 @@ function (locale, dom, style) {
return key.toLowerCase();
},

detectionStatusToString : function (detectionStatus) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be an unused method.

from libtest import env


class TestSkeleton(unittest.TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test class uses template name.


def _create_source_file(self, version):
if version == 1:
source = """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we could put the later hardcoded bug hashes here at least as a comment to see which means which bug in the code.

def unzip(b64zip):
"""
This function unzips the base64 encoded zip file which should contain
exactly one directory. This directory is extracted to the given workspace.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method no longer uses a "workspace", the docstring should reflect that.

@@ -20,6 +27,10 @@
from codeCheckerDBAccess import constants
from codeCheckerDBAccess.ttypes import *

from libcodechecker import generic_package_context
from libcodechecker import suppress_handler
from libcodechecker.analyze import plist_parser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment at the .analyze import

# TODO: Cross-subpackage import here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. But what's this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Back when the subcommands and the whole of libcodechecker was split and reorganised, imports which violated subcommand boundaries (such as server depending on a class defined in analyze) were marked with the same(-esque) TODO.

It's a marker for us that there are architectural mishaps in CodeChecker. It's not a problem as long as CodeChecker is a single and whole being in itself, but the moment we want to create separate builds from CodeChecker, e.g. one that can only log and analyze, or one that is only a webserver, these imports make easy creation of such packages problematic, and these markers show us that "Yeah, there should one day be a refactoring here!". (There were discussion about this package separation around 7-9 months ago, but that discussion died due to the plethora of other features to be made.)

import tempfile
import zlib

import shared
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import order is: systemwide, external, API, internal, local.

So:

  1. import zlib
  2. (empty line)
  3. import sqlalchemy
  4. (empty line)
  5. import shared
  6. from codeCheckerDBAcess...

bool setRunDuration(1: i64 run_id,
2: i64 duration)
throws (1: shared.RequestFailed requestError),

bool stopServer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is absolutely not used anywhere in the code. We should remove it too, if we are already throwing out a big hunk here.

'hello',
self._test_dir)

def test_skel(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is template text


def test_skel(self):
"""
Test some feature.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a text from the test template


def setUp(self):
"""
WARNING!!!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text is from the test template


""" detection_status function test.

WARNING!!!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test remained here from the test template


"""Setup for the test package detection_status.

WARNING!!!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text remained here from the test template

@@ -15,9 +15,10 @@ define([
'dijit/form/TextBox',
'dijit/layout/BorderContainer',
'dijit/layout/ContentPane',
'dojox/grid/DataGrid'],
'dojox/grid/DataGrid',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep an import order in the JS code too: dijit/form/..., dijit/grid/..., dijit/layout/....

Don't forget to align the variable names in the function decl below!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dojox/grid, not dijit/grid.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my bad, then. 😇


events = filter(lambda i: i.get('kind') == 'event', report.bug_path)

# TODO: skip handling
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now the idea is that skip handling will be done after the analysis so the storage does not have to skip the results.

@@ -823,6 +1007,9 @@ def __queryDiffResults(self,
.outerjoin(File, Report.file_id == File.id) \
.outerjoin(ReviewStatus,
ReviewStatus.bug_hash == Report.bug_id) \
.outerjoin(SuppressBug,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we remove the SuppressBug table?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did, in #768.


# Get the CodeChecker cmd if needed for the tests.
self._codechecker_cmd = env.codechecker_cmd()
self._test_dir = os.path.join(os.path.dirname(__file__), 'test_files')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend to use the workspace created for the tests to generate test files. Not to the test file directory.

@@ -31,6 +31,8 @@ struct RunData{
6: string runCmd, // the used check command
7: optional bool can_delete // true if codeCheckerDBAccess::removeRunResults()
// is allowed on this run (see issue 151)
8: map<shared.DetectionStatus, i32> detectionStatusCount
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be a separate count api with filtering if the schema is ready. I'm not sure we should return this value here. For now we can keep it.

Copy link
Contributor

@whisperity whisperity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the inline comments, considering that we are only packaging in store, the --jobs argument is irrelevant. It should be removed.

It's argument forwarding in the wrapper check should also be removed.


shutil.copyfile(f, target_file)

zipf = zipfile.ZipFile(zip_file, 'w')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zipfile.ZipFile can be used as a context manager:

with zipfile.ZipFile(zip_file, 'w') as zipf:
    for root, _, files in os.walk(temp_dir):
        # ...


shutil.copyfile(f, target_file)

zipf = zipfile.ZipFile(zip_file, 'w')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ZIP file in its current state does not deflate the files, only store them. If this is intended, it's allright, you create a compression later on, actually creating a .zip.gz.

If we'd rather individually compress the files, we should add a 3rd argument to this constructor: zipfile.DEFLATED.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .zip file is compressed later in one piece when it's already containing everything. I'm not writing the compressed file to the disk to a .zip.gz, but I'm sending the data directly to the server.

LOG = LoggerFactory.get_new_logger('STORE HANDLER')


def process_compile_db(compile_db):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a more descriptive name like make_absolute_path_compile_db. Process is overly generic in my opinion.

if not os.path.exists(compile_db):
LOG.warning("Compilation command file '" + compile_db +
"' is missing.")
LOG.warning("Update mode will not work, without compilation "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhere we should have a ticket to extend the plist with a working directory entry to overcome this issue in the long term.

metadata_dict = json.load(metadata)
LOG.debug(metadata_dict)

if 'command' in metadata_dict:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this code to be in the with block?


with open(metadata_file, 'r') as metadata:
metadata_dict = json.load(metadata)
LOG.debug(metadata_dict)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to dump the content of this file?

start2_line,
start2_col,
file_ids[source_file_path]))
except IndexError:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this worth a comment what kind of lookups do we expect to fail and why.

try:
LOG.debug("adding checker run")

run = session.query(Run).filter(Run.name == name).first()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use one_or_none to enforce that there are no multiple runs with the same name?

@bruntib bruntib force-pushed the detection_status branch 2 times, most recently from 1de081b to ef70176 Compare August 18, 2017 09:58
Store detection status for the reports in the database.
Copy link
Member

@dkrupp dkrupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Please clean up the naming in the API and add a few more test cases.

9: ReviewData review // bug review status informations.
1: string checkerId, // the qualified id of the checker that reported this
2: string bugHash, // This is unique id of the concrete report.
3: string checkedFile, // this is a filepath
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkedFile is confusing indeed. Maybe sourceFileName would be a better name...

// The "version" parameter is the used CodeChecker version which checked this
// run.
// The "force" parameter removes existing analysis results for a run.
i64 storeZip(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry a naming comment again: Please rename this function: storeRun(...)
or maybe massStoreRun() to better express the functionality.

Because that's what this function is really functionally doing.
Requiring zip format is an accidental design choice, it could have been rar as well, but still the function stores a run...

1: string run_name,
2: string version,
3: string zipfile,
4: bool force)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe clean is a better name as it expresses that previous results will be cleaned for this run.


int* p = 0;

i = *p + 42;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a version 4 of the file where you insert 2 blank lines after int main(){ to test if the bugs are not duplicated with line shift.

shared.ttypes.DetectionStatus.REOPENED)
elif report.bugHash == 'ac147b31a745d91be093bd70bbc5567c':
self.assertEqual(report.detectionStatus,
shared.ttypes.DetectionStatus.RESOLVED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please also verify the source file content referred to by the bug.
for the resolved bug (i.e. i=1/0 we should see version 2) we should see the last version where the bug occurred, for new, unresolved, and reopened, we should always see the latest file content.

@bruntib bruntib force-pushed the detection_status branch 2 times, most recently from 99d53ad to 859844b Compare August 18, 2017 13:51
@bruntib bruntib force-pushed the detection_status branch 2 times, most recently from f8da1a5 to 73aad57 Compare August 18, 2017 15:10
"analyze",
"asd.json"],
"failed": {},
"working_directory": "/home/etibbru/CodeCompass/projects/hello",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work for other users?

"failed": {},
"working_directory": "/home/etibbru/CodeCompass/projects/hello",
"timestamps": {"begin": 1502964665.566252, "end": 1502964665.777198},
"output_path": "/home/etibbru/.codechecker/reports"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A user-related path is added here too.

Copy link
Contributor

@whisperity whisperity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's roll this at this point. Some issues remain, they will be fixed later on.

@whisperity whisperity merged commit 81d8764 into Ericsson:version6 Aug 18, 2017
@bruntib bruntib deleted the detection_status branch August 18, 2017 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change 📄 Content of patch changes API! CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands database 🗄️ Issues related to the database schema. GUI 🎨 WARN ⚠️: Backward compatibility breaker! MIND THE GAP! Merging this patch will mess up compatibility with the previous releases!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants