Skip to content

Conversation

@TheAngryByrd
Copy link
Member

@TheAngryByrd TheAngryByrd commented Jun 27, 2025

Closes #234

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request introduces support for F# script files in the analyzer CLI while updating error codes and documentation to reflect the new functionality.

  • Adds a new "Script" argument to accept .fsx files and implements glob-based file matching.
  • Updates various exit points to use more descriptive error codes via the ExitErrorCodes enum.
  • Updates documentation and package metadata accordingly.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/FSharp.Analyzers.Cli/Program.fs Adds script file support, new error codes, and refines argument validation.
samples/BadOptionUsage.fsx Introduces a sample script demonstrating potential OptionAnalyzer warnings.
global.json Updates the SDK configuration with rollForward policy.
docs/index.md Adds examples for running the CLI against script files.
Directory.Packages.props Bumps the Argu package version.
Comments suppressed due to low confidence (1)

src/FSharp.Analyzers.Cli/Program.fs:744

  • [nitpick] Consider handling '--project' and '--script' conflicts with '--fsc-args' separately using distinct error codes or messages. This may provide clearer troubleshooting by identifying which mutually exclusive option is causing the conflict.
            match fscArgs with

<PackageVersion Include="Ionide.KeepAChangelog.Tasks" Version="0.1.8" PrivateAssets="all" />
<PackageVersion Include="McMaster.NETCore.Plugins" Version="1.4.0" />
<PackageVersion Include="Argu" Version="6.1.1" />
<PackageVersion Include="Argu" Version="6.2.5" />
Copy link
Member Author

Choose a reason for hiding this comment

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

Had to update Argu to deal with the Compiler attribute issue

open FSharp.Analyzers.Cli.CustomLogging


type ExitErrorCodes =
Copy link
Member Author

Choose a reason for hiding this comment

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

Since we have exit 1 in like 100 places, I decided it's time to make exit codes specific to errors.

Comment on lines +628 to +638
if Path.IsPathRooted scriptGlob then
// Glob can't handle absolute paths, so we need to make sure the scriptGlob is a relative path
let root = Path.GetPathRoot scriptGlob
let glob = scriptGlob.Substring(root.Length)
DirectoryInfo root, glob
else if beginsWithCurrentPath scriptGlob then
// Glob can't handle relative paths starting with "./" or ".\", so we need trim it
let relativeGlob = scriptGlob.Substring(2) // remove "./" or ".\"
cwd, relativeGlob
else
cwd, scriptGlob
Copy link
Member Author

Choose a reason for hiding this comment

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

Some annoying path math

Copy link
Contributor

Choose a reason for hiding this comment

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

If Glob doesn't support this stuff and hasn't been updated for some time, is it worth seeing if Microsoft.Extensions.FileSystemGlobbing would work? (as it's still updated, and doesn't have any depenencies)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ooo didn’t know this existed. Would gladly replace it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ended up being a little more difficult because of how we curently use and I didn't want to spend that much time on it. Could be a good change for a subsequent PR.

@TheAngryByrd TheAngryByrd marked this pull request as ready for review June 28, 2025 17:56
@TheAngryByrd
Copy link
Member Author

This will probably conflict slightly with #236 but shouldn't be hard to fix either if one goes in first.

@TheAngryByrd TheAngryByrd force-pushed the 234-support-script-files branch from 0da7635 to 110b237 Compare June 28, 2025 18:44
Copy link
Contributor

@nojaf nojaf left a comment

Choose a reason for hiding this comment

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

Great stuff, well done!

@TheAngryByrd TheAngryByrd merged commit cbb751d into main Jul 12, 2025
2 checks passed
@TheAngryByrd TheAngryByrd changed the title 234 support script files support script files Jul 12, 2025
@TheAngryByrd TheAngryByrd changed the title support script files Support script files Jul 12, 2025
@TheAngryByrd TheAngryByrd changed the title Support script files Support script (fsx) files Jul 12, 2025
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.

Support Script (fsx) files

4 participants