Skip to content

Repair rubocop refusing to run (#97) - #262

Merged
nikhil2611 merged 8 commits into
chef:mainfrom
sinfomicien:update-and-repair-extension
Aug 17, 2026
Merged

Repair rubocop refusing to run (#97)#262
nikhil2611 merged 8 commits into
chef:mainfrom
sinfomicien:update-and-repair-extension

Conversation

@sinfomicien

@sinfomicien sinfomicien commented Apr 7, 2025

Copy link
Copy Markdown
Contributor

Description

As i start to look into the problem, got multiples problem to handle. So i tried to correct them all:

  • Upgrade dependencies
  • Use ESlint instead of TSLint(obsolete)
  • Remove a null token parameter in findFiles call, generating extension load error
  • Replace rootPath (deprecated) by workspaceFolders[0].uri.fsPath
  • Correct a language/snippet file loading problem(berkshelf vs berkfile) (Extension issue #142)
  • added shell: true in spawn execution, it was failing without with node 20.
  • Removed test from node 15 (unsupported)
  • Adding test for node 18 and node 20.
  • Change gif image URL in README (master branch is now main)
  • Escape $ from some snippet description to avoid warning in VSCode

Now, all problems are correctly highlighted (even if for now, it’s not possible to correct them automatically).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • If Gemfile.lock has changed, I have used --conservative to do it and included the full output in the Description above.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

@sinfomicien
sinfomicien requested review from a team as code owners April 7, 2025 12:59
@sinfomicien
sinfomicien force-pushed the update-and-repair-extension branch from e89f937 to 3519ab6 Compare April 7, 2025 13:04
@sinfomicien sinfomicien mentioned this pull request Apr 7, 2025
@sinfomicien
sinfomicien force-pushed the update-and-repair-extension branch from 3519ab6 to 6d617ee Compare April 7, 2025 13:08
@sinfomicien
sinfomicien force-pushed the update-and-repair-extension branch from 6d617ee to 7402d95 Compare April 7, 2025 13:16
@sinfomicien
sinfomicien requested a review from a team as a code owner April 7, 2025 13:16
- Upgrade dependencies
- Use ESlint instead of TSLint(obsolete)
- Remove a null token parameter in findFiles call, generating extension load error
- Replace rootPath (deprecated) by workspaceFolders[0].uri.fsPath
- Correct a language/snippet file loading problem(berkshelf vs berkfile) (chef#142)
- Correct gif image url in README (master branch now is main)
- Escape $ in some snippet description to avoid warning from VSCode

Signed-off-by: Nicolas Blanc <sinfomicien@gmail.com>
@sinfomicien
sinfomicien force-pushed the update-and-repair-extension branch from 7402d95 to 260aa8c Compare April 7, 2025 14:50
@sonarqubecloud

sonarqubecloud Bot commented Apr 7, 2025

Copy link
Copy Markdown

@sinfomicien

Copy link
Copy Markdown
Contributor Author

@clintoncwolfe , is it possible to review this PR ? Could it be merged at some point ?

@sinfomicien

Copy link
Copy Markdown
Contributor Author

@nikhil2611 could you review the PR please ?

@nikhil2611

nikhil2611 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Hey @sinfomicien , Please review the updated changes

nikhil2611 and others added 3 commits August 14, 2026 19:12
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: nikhil2611 <ngupta@progress.com>
- Add null/undefined checks before accessing workspaceFolders[0]
- Prevent runtime errors when no workspace is open
- Extract workspaceRoot to const for cleaner code and single access point

Signed-off-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: nikhil2611 <ngupta@progress.com>
nikhil2611
nikhil2611 previously approved these changes Aug 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to get the VS Code Chef extension back into a healthy/runnable state by addressing several extension activation, linting, and language/snippet loading issues (including the Berksfile grammar wiring mentioned in #142), alongside dependency/CI maintenance updates.

Changes:

  • Adds/rewires Berksfile language grammar support (new chef_berksfile syntax file + package.json grammar entry changes).
  • Adjusts Rubocop/Cookstyle execution logic (workspace folder handling, spawn options) and fixes a findFiles call signature issue.
  • Updates snippet content to avoid $-related snippet parsing warnings and refreshes a README asset URL.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
syntaxes/chef_berksfile.cson.json Introduces a Berksfile TextMate grammar shim (includes Ruby scope).
snippets/chef_inspec_resources.json Escapes $ in snippet bodies and adjusts a couple of description strings.
README.md Updates the install/demo GIF URL.
package.json Updates activation/grammar contributions, including Berksfile grammar mapping.
extension.ts Fixes findFiles token usage, updates workspace root handling, and adjusts Rubocop spawning.
.github/dependabot.yml Removes dependency ignore rules.
Suppressed comments (1)

snippets/chef_inspec_resources.json:2711

  • Snippet description strings are displayed as plain text; escaping $ here will show the backslash to users (e.g. \$ORACLE_HOME). Keep $ORACLE_HOME unescaped in the description and only escape $ where snippet parsing occurs (the body).
    "description": "Use the `oracledb_listener_conf` Chef InSpec audit resource to test the listeners settings of Oracle DB, typically located at `\\$ORACLE_HOME/network/admin/listener.ora` or `\\$ORACLE_HOME\\network\\admin\\listener.ora` depending upon the platform.",

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread package.json Outdated
Comment thread extension.ts
Comment thread extension.ts
Comment thread README.md Outdated
Comment thread snippets/chef_inspec_resources.json Outdated
- Fix scopeName mismatch in package.json (source.chef.chef_berksfile → source.chef.berksfile)
- Add workspace trust check before executing external binaries
- Make shell option conditional (Windows only) to reduce security risk
- Fix README image URL to use raw.githubusercontent.com
- Remove unnecessary escaping from snippet descriptions (keep in body only)

These changes improve security, correctness, and user experience.

Signed-off-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: nikhil2611 <ngupta@progress.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: nikhil2611 <ngupta@progress.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (2)

package.json:30

  • With only workspaceContains:**/metadata.rb in activationEvents, the extension won’t activate for non-cookbook workspaces (for example, InSpec profiles) even though this extension contributes chef_inspec/chef_berksfile languages. That prevents linting/commands from running unless a metadata.rb exists. Consider re-adding onLanguage:* activation events for the Chef languages so the extension activates when those file types are opened.
  "activationEvents": [
    "workspaceContains:**/metadata.rb"
  ],

extension.ts:231

  • shell: isWindows was added for the main rubocop run here, but checkCookstyleVersion() still spawns rubocopPath without shell. On Windows, rubocopPath is a .bat (see candidate paths), so the version check is likely to fail even though the main lint run now works. Please apply the same shell handling to the version check spawn as well.
		const isWindows = process.platform === 'win32';
		let spawn = require("child_process").spawnSync;
		let rubocop: any;
		if (rubocopConfigFile) {
			rubocop = spawn(rubocopPath, ["--parallel", "--config", rubocopConfigFile, "-f", "j"].concat(paths), { shell: isWindows, cwd: workspaceRoot });

@sinfomicien

Copy link
Copy Markdown
Contributor Author

Everything seems ok to me !

@sanghinitin sanghinitin left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@nikhil2611
nikhil2611 merged commit 398e5ac into chef:main Aug 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants