Skip to content

Commit 3bb5837

Browse files
committed
CM-55551 - fix linter check comments
1 parent f4d0a5e commit 3bb5837

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

cycode/cli/files_collector/sca/npm/restore_npm_dependencies.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def _create_document_from_lockfile(
7777
Args:
7878
document: Original document (package.json).
7979
lockfile_path: Path to the existing lockfile.
80-
80+
8181
Returns:
8282
Document with lockfile content if successful, None otherwise.
8383
"""
@@ -96,20 +96,20 @@ def _create_document_from_lockfile(
9696
{'path': document.path, 'lockfile': lock_file_name, 'content_size': len(restore_file_content)},
9797
)
9898
return Document(relative_restore_file_path, restore_file_content, self.is_git_diff)
99-
else:
100-
logger.warning(
101-
'Lockfile exists but could not read content, %s',
102-
{'path': document.path, 'lockfile': lock_file_name, 'lockfile_path': lockfile_path},
103-
)
104-
return None
99+
100+
logger.warning(
101+
'Lockfile exists but could not read content, %s',
102+
{'path': document.path, 'lockfile': lock_file_name, 'lockfile_path': lockfile_path},
103+
)
104+
return None
105105

106106
def try_restore_dependencies(self, document: Document) -> Optional[Document]:
107107
"""Override to prevent npm install when any lockfile exists.
108108
109109
The base class uses document.absolute_path which might be None or incorrect.
110110
We need to use the same path resolution logic as get_manifest_file_path()
111111
to ensure we check for lockfiles in the correct location.
112-
112+
113113
If any lockfile exists (package-lock.json, pnpm-lock.yaml, yarn.lock, deno.lock),
114114
we use it directly without running npm install to avoid generating invalid lockfiles.
115115
"""
@@ -128,7 +128,8 @@ def try_restore_dependencies(self, document: Document) -> Optional[Document]:
128128
return super().try_restore_dependencies(document)
129129

130130
# Check for existing lockfiles
131-
logger.debug('Checking for existing lockfiles in directory, %s', {'directory': manifest_dir, 'path': document.path})
131+
logger.debug('Checking for existing lockfiles in directory, %s',
132+
{'directory': manifest_dir, 'path': document.path})
132133
existing_lock_file, checked_lockfiles = self._find_existing_lockfile(manifest_dir)
133134

134135
logger.debug(
@@ -176,6 +177,5 @@ def prepare_manifest_file_path_for_command(manifest_file_path: str) -> str:
176177
# Handle both cases: with separator (e.g., '/path/to/package.json') and without (e.g., 'package.json')
177178
if os.sep in manifest_file_path:
178179
return manifest_file_path.replace(os.sep + NPM_MANIFEST_FILE_NAME, '')
179-
else:
180-
return ''
180+
return ''
181181
return manifest_file_path

tests/cli/files_collector/sca/npm/__init__.py

Whitespace-only changes.

tests/cli/files_collector/sca/npm/test_restore_npm_dependencies.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TestRestoreNpmDependenciesAlternativeLockfiles:
3131
"""Test that lockfiles prevent npm install from running."""
3232

3333
@pytest.mark.parametrize(
34-
'lockfile_name,lockfile_content,expected_content',
34+
('lockfile_name,lockfile_content,expected_content'),
3535
[
3636
('pnpm-lock.yaml', 'lockfileVersion: 5.4\n', 'lockfileVersion: 5.4\n'),
3737
('yarn.lock', '# yarn lockfile v1\n', '# yarn lockfile v1\n'),
@@ -90,7 +90,7 @@ def test_no_lockfile_exists_should_proceed_with_normal_flow(
9090
return_value=None,
9191
) as mock_super:
9292
# Execute
93-
result = restore_npm_dependencies.try_restore_dependencies(document)
93+
restore_npm_dependencies.try_restore_dependencies(document)
9494

9595
# Verify: Should call parent's try_restore_dependencies (which will run npm install)
9696
mock_super.assert_called_once_with(document)
@@ -239,7 +239,8 @@ def test_multiple_lockfiles_should_use_first_found(
239239
def test_multiple_alternative_lockfiles_should_use_first_found(
240240
self, restore_npm_dependencies: RestoreNpmDependencies, tmp_path: Path
241241
) -> None:
242-
"""Test that when multiple alternative lockfiles exist (but no package-lock.json), the first one found is used."""
242+
"""Test that when multiple alternative lockfiles exist (but no package-lock.json),
243+
the first one found is used."""
243244
package_json_path = tmp_path / 'package.json'
244245
yarn_lock_path = tmp_path / 'yarn.lock'
245246
pnpm_lock_path = tmp_path / 'pnpm-lock.yaml'
@@ -285,7 +286,7 @@ def test_lockfile_in_different_directory_should_not_be_found(
285286
'try_restore_dependencies',
286287
return_value=None,
287288
) as mock_super:
288-
result = restore_npm_dependencies.try_restore_dependencies(document)
289+
restore_npm_dependencies.try_restore_dependencies(document)
289290

290291
# Should proceed with normal flow since lockfile not in same directory
291292
mock_super.assert_called_once_with(document)

0 commit comments

Comments
 (0)