Skip to content

Commit

Permalink
skip configuration will not be stored (#920)
Browse files Browse the repository at this point in the history
* skipping reports or analysis should be handled at the analysis part
  • Loading branch information
gyorb authored and Xazax-hun committed Sep 14, 2017
1 parent 162dde6 commit 82b45a4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 96 deletions.
36 changes: 1 addition & 35 deletions libcodechecker/analyze/store_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
def metadata_info(metadata_file):
check_commands = []
check_durations = []
skip_handlers = []

with open(metadata_file, 'r') as metadata:
metadata_dict = json.load(metadata)
Expand All @@ -38,19 +37,8 @@ def metadata_info(metadata_file):
check_durations.append(
float(metadata_dict['timestamps']['end'] -
metadata_dict['timestamps']['begin']))
if 'skip_data' in metadata_dict:
# Save previously stored skip data for sending to the
# database, to ensure skipped headers are actually
# skipped --- 'analyze' can't do this.
handle, path = tempfile.mkstemp()
with os.fdopen(handle, 'w') as tmpf:
tmpf.write('\n'.join(metadata_dict['skip_data']))

skip_handlers.append(
skiplist_handler.SkipListHandler(path))
os.remove(path)

return check_commands, check_durations, skip_handlers
return check_commands, check_durations


def collect_paths_events(report, file_ids, files):
Expand Down Expand Up @@ -401,28 +389,6 @@ def addReport(storage_session,
str(ex))


def addSkipPath(storage_session, run_id, paths):
"""
"""
try:
session = storage_session.get_transaction(run_id)

count = session.query(SkipPath) \
.filter(SkipPath.run_id == run_id) \
.delete()
LOG.debug('SkipPath: ' + str(count) + ' removed item.')

skipPathList = []
for path, comment in paths.items():
skipPath = SkipPath(run_id, path, comment)
skipPathList.append(skipPath)
session.bulk_save_objects(skipPathList)
return True
except Exception as ex:
LOG.error(str(ex))
return False


def addFileContent(session, filepath, content, encoding):
"""
Add the necessary file contents. If the file is already stored in the
Expand Down
7 changes: 0 additions & 7 deletions libcodechecker/libhandlers/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,6 @@ def main(args):
if 'name' in args:
metadata['name'] = args.name

if 'skipfile' in args:
# Skip information needs to be saved because reports in a header
# can only be skipped by the report-server used in 'store' later
# on if this information is persisted.
with open(args.skipfile, 'r') as skipfile:
metadata['skip_data'] = [l.strip() for l in skipfile.readlines()]

# Update metadata dictionary with old values.
metadata_file = os.path.join(args.output_path, 'metadata.json')
if os.path.exists(metadata_file):
Expand Down
37 changes: 1 addition & 36 deletions libcodechecker/server/client_db_access_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,32 +1096,6 @@ def getCheckerConfigs(self, run_id):
finally:
session.close()

@timeit
def getSkipPaths(self, run_id):
self.__require_access()
try:
session = self.__Session()

suppressed_paths = session.query(SkipPath) \
.filter(SkipPath.run_id == run_id) \
.all()

results = []
for sp in suppressed_paths:
encoded_path = sp.path
encoded_comment = sp.comment
results.append(SkipPathData(encoded_path, encoded_comment))

return results

except sqlalchemy.exc.SQLAlchemyError as alchemy_ex:
msg = str(alchemy_ex)
LOG.error(msg)
raise shared.ttypes.RequestFailed(shared.ttypes.ErrorCode.DATABASE,
msg)
finally:
session.close()

@timeit
def getSourceFileData(self, fileId, fileContent, encoding):
"""
Expand Down Expand Up @@ -1596,7 +1570,7 @@ def massStoreRun(self, name, version, b64zip, force):
with open(content_hash_file) as chash_file:
filename2hash = json.load(chash_file)

check_commands, check_durations, skip_handlers = \
check_commands, check_durations = \
store_handler.metadata_info(metadata_file)

if len(check_commands) == 0:
Expand Down Expand Up @@ -1653,8 +1627,6 @@ def massStoreRun(self, name, version, b64zip, force):
with codecs.open(source_file_name, 'r',
'UTF-8', 'replace') as source_file:
file_content = source_file.read()
# TODO: we may not use the file content in the end
# depending on skippaths.
file_content = codecs.encode(file_content, 'utf-8')

file_path_to_id[file_name] = \
Expand All @@ -1672,13 +1644,6 @@ def massStoreRun(self, name, version, b64zip, force):

session = self.__storage_session.get_transaction(run_id)

# Handle skip list.
for skip_handler in skip_handlers:
if not store_handler.addSkipPath(self.__storage_session,
run_id,
skip_handler.get_skiplist()):
LOG.debug("Adding skip path failed!")

# Processing PList files.
_, _, report_files = next(os.walk(report_dir), ([], [], []))
for f in report_files:
Expand Down
18 changes: 0 additions & 18 deletions libcodechecker/server/run_db_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,24 +221,6 @@ def __init__(self, run_id, bug_id, file_id, checker_message, checker_id,
self.column = column


class SkipPath(Base):
__tablename__ = 'skip_paths'

id = Column(Integer, autoincrement=True, primary_key=True)
path = Column(String)
run_id = Column(Integer,
ForeignKey('runs.id', deferrable=True,
initially="DEFERRED",
ondelete='CASCADE'),
nullable=False)
comment = Column(Binary)

def __init__(self, run_id, path, comment):
self.path = path
self.run_id = run_id
self.comment = comment


class Comment(Base):
__tablename__ = 'comments'

Expand Down

0 comments on commit 82b45a4

Please sign in to comment.