Skip to content

Commit

Permalink
Address code review comments and some Differential PyLint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lbossis committed Aug 17, 2023
1 parent 66ca1d6 commit f115b7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions py/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with csmock. If not, see <http://www.gnu.org/licenses/>.

import re
import os
import re


def shell_quote(str_in):
Expand Down Expand Up @@ -125,8 +125,12 @@ def dirs_to_scan_by_args(parser, args, props, tool):


def handle_known_fp_list(props):
"""
This function definition has been moved here from py/csmock
in order to expose it for potential use where it might fit
"""
# install global filter of known false positives
filter_cmd = 'csdiff --json-output --show-internal "%s" -' % props.known_false_positives
filter_cmd = f"csdiff --json-output --show-internal \"{props.known_false_positives}\""
props.result_filters += [ filter_cmd ]

if props.pkg is None:
Expand All @@ -144,10 +148,10 @@ def handle_known_fp_list(props):
return

# install path exclusion filters for this pkg
with open(ep_file) as f:
lines = f.readlines()
for l in lines:
path_re = l.strip()
filter_cmd = 'csgrep --mode=json --invert-match --path=%s' % shell_quote(path_re)
with open(ep_file) as fp:

Check warning

Code scanning / vcs-diff-lint

handle_known_fp_list: Using open without explicitly specifying an encoding Warning

handle_known_fp_list: Using open without explicitly specifying an encoding

Check warning

Code scanning / vcs-diff-lint

handle_known_fp_list: Variable name "fp" doesn't conform to snake_case naming style Warning

handle_known_fp_list: Variable name "fp" doesn't conform to snake_case naming style
lines = fp.readlines()
for line in lines:
path_re = line.strip()
filter_cmd = f"csgrep --mode=json --invert-match --path={shell_quote(path_re)}"
props.result_filters += [ filter_cmd ]

Check warning

Code scanning / vcs-diff-lint

Trailing newlines Warning

Trailing newlines
2 changes: 1 addition & 1 deletion py/csmock
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import time

# local imports
import csmock.common.util
from csmock.common.util import handle_known_fp_list
from csmock.common.util import shell_quote
from csmock.common.util import strlist_to_shell_cmd
from csmock.common.util import handle_known_fp_list
from csmock.common.results import FatalError
from csmock.common.results import ScanResults
from csmock.common.results import transform_results
Expand Down

0 comments on commit f115b7e

Please sign in to comment.