From 856e26928af90dd635b657dc2ba12e6eeadafd60 Mon Sep 17 00:00:00 2001 From: Akshet Pandey Date: Sun, 26 May 2024 15:55:52 -0400 Subject: [PATCH 1/3] S113 request-without-timeout should also warn about `requests.request` call without timeout --- .../src/rules/flake8_bandit/rules/request_without_timeout.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ruff_linter/src/rules/flake8_bandit/rules/request_without_timeout.rs b/crates/ruff_linter/src/rules/flake8_bandit/rules/request_without_timeout.rs index 26152e9ef76b2..3497e681b6087 100644 --- a/crates/ruff_linter/src/rules/flake8_bandit/rules/request_without_timeout.rs +++ b/crates/ruff_linter/src/rules/flake8_bandit/rules/request_without_timeout.rs @@ -58,7 +58,7 @@ pub(crate) fn request_without_timeout(checker: &mut Checker, call: &ast::ExprCal qualified_name.segments(), [ "requests", - "get" | "options" | "head" | "post" | "put" | "patch" | "delete" + "get" | "options" | "head" | "post" | "put" | "patch" | "delete" | "request" ] ) }) From 8dab85d832b23c5c6389ad2a52c006e0122cede1 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 28 May 2024 12:07:19 -0400 Subject: [PATCH 2/3] Set max --- python/ruff-ecosystem/ruff_ecosystem/check.py | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/python/ruff-ecosystem/ruff_ecosystem/check.py b/python/ruff-ecosystem/ruff_ecosystem/check.py index 680b5f204d3c8..d863e82f84900 100644 --- a/python/ruff-ecosystem/ruff_ecosystem/check.py +++ b/python/ruff-ecosystem/ruff_ecosystem/check.py @@ -36,7 +36,6 @@ Project, ) - # Matches lines that are summaries rather than diagnostics CHECK_SUMMARY_LINE_RE = re.compile(r"^(Found \d+ error.*)|(.* fixable with .*)$") @@ -80,7 +79,7 @@ def markdown_check_result(result: Result) -> str: total_added_fixes = all_rule_changes.total_added_fixes() total_removed_fixes = all_rule_changes.total_removed_fixes() total_changes = ( - total_added + total_removed + total_added_fixes + total_removed_fixes + total_added + total_removed + total_added_fixes + total_removed_fixes ) error_count = len(result.errored) total_affected_rules = len(all_rule_changes.rule_codes()) @@ -137,10 +136,10 @@ def markdown_check_result(result: Result) -> str: project_added_fixes = rule_changes.total_added_fixes() project_removed_fixes = rule_changes.total_removed_fixes() project_changes = ( - project_added_violations - + project_removed_violations - + project_added_fixes - + project_removed_fixes + project_added_violations + + project_removed_violations + + project_added_fixes + + project_removed_fixes ) # Limit the number of items displayed per project to between 10 and 50 @@ -154,7 +153,7 @@ def markdown_check_result(result: Result) -> str: # skip display. This shouldn't really happen and indicates a problem in the # calculation of these values. Instead of skipping entirely when `total_changes` # is zero, we'll attempt to report the results to help diagnose the problem. - project_changes / max(total_changes, 1) + project_changes / max(total_changes, 1) ) * 50 ), @@ -163,7 +162,7 @@ def markdown_check_result(result: Result) -> str: # Limit the number of items displayed per rule to between 5 and the max for # the project based on the number of rules affected (less rules, more per rule) max_display_per_rule = max( - 5, max_display_per_project // len(rule_changes.rule_codes()) + 5, max_display_per_project // max(len(rule_changes.rule_codes()), 1) ) # Display the diff @@ -189,11 +188,11 @@ def markdown_check_result(result: Result) -> str: # If we just reached the maximum... display an omission line if displayed_changes_per_rule[rule_code] > max_display_per_rule: hidden_count = ( - rule_changes.added_violations[rule_code] - + rule_changes.removed_violations[rule_code] - + rule_changes.added_fixes[rule_code] - + rule_changes.removed_fixes[rule_code] - - max_display_per_rule + rule_changes.added_violations[rule_code] + + rule_changes.removed_violations[rule_code] + + rule_changes.added_fixes[rule_code] + + rule_changes.removed_fixes[rule_code] + - max_display_per_rule ) diff_lines.append( f"... {hidden_count} additional changes omitted for rule {rule_code}" @@ -244,9 +243,9 @@ def markdown_check_result(result: Result) -> str: ) table_lines.append("| ---- | ------- | --------- | -------- | ----- | ---- |") for rule, total in sorted( - all_rule_changes.total_changes_by_rule(), - key=lambda item: item[1], # Sort by the total changes - reverse=True, + all_rule_changes.total_changes_by_rule(), + key=lambda item: item[1], # Sort by the total changes + reverse=True, ): added_violations, removed_violations, added_fixes, removed_fixes = ( all_rule_changes.added_violations[rule], @@ -433,10 +432,10 @@ class CheckDiff(Diff): """ def __init__( - self, - lines: Iterable[str], - parsed_lines: list[DiagnosticLine], - fix_only_lines: set[DiagnosticLine], + self, + lines: Iterable[str], + parsed_lines: list[DiagnosticLine], + fix_only_lines: set[DiagnosticLine], ) -> None: self.parsed_lines = parsed_lines self.fix_only_lines = fix_only_lines @@ -493,11 +492,11 @@ def add_permalink_to_diagnostic_line(repo: ClonedRepository, line: str) -> str: async def compare_check( - ruff_baseline_executable: Path, - ruff_comparison_executable: Path, - options: CheckOptions, - config_overrides: ConfigOverrides, - cloned_repo: ClonedRepository, + ruff_baseline_executable: Path, + ruff_comparison_executable: Path, + options: CheckOptions, + config_overrides: ConfigOverrides, + cloned_repo: ClonedRepository, ) -> Comparison: with config_overrides.patch_config(cloned_repo.path, options.preview): async with asyncio.TaskGroup() as tg: @@ -529,7 +528,7 @@ async def compare_check( async def ruff_check( - *, executable: Path, path: Path, name: str, options: CheckOptions + *, executable: Path, path: Path, name: str, options: CheckOptions ) -> Sequence[str]: """Run the given ruff binary against the specified path.""" ruff_args = options.to_ruff_args() From a3db1b6db18671e9ac4f6d4af232a9eb02b146d8 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Tue, 28 May 2024 12:27:18 -0400 Subject: [PATCH 3/3] Revert check --- python/ruff-ecosystem/ruff_ecosystem/check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/ruff-ecosystem/ruff_ecosystem/check.py b/python/ruff-ecosystem/ruff_ecosystem/check.py index d863e82f84900..1705dc142ddcc 100644 --- a/python/ruff-ecosystem/ruff_ecosystem/check.py +++ b/python/ruff-ecosystem/ruff_ecosystem/check.py @@ -162,7 +162,7 @@ def markdown_check_result(result: Result) -> str: # Limit the number of items displayed per rule to between 5 and the max for # the project based on the number of rules affected (less rules, more per rule) max_display_per_rule = max( - 5, max_display_per_project // max(len(rule_changes.rule_codes()), 1) + 5, max_display_per_project // len(rule_changes.rule_codes()) ) # Display the diff