Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Third party .editorconfig leading to: Error Failure parsing editorconfig files #1227

Closed
K0Te opened this issue Apr 16, 2024 · 1 comment · Fixed by #1229
Closed

Third party .editorconfig leading to: Error Failure parsing editorconfig files #1227

K0Te opened this issue Apr 16, 2024 · 1 comment · Fixed by #1229
Milestone

Comments

@K0Te
Copy link

K0Te commented Apr 16, 2024

Environments:

  • CSharpier Version: 0.26.7 and current main
  • Running CSharpier via: cli
  • Operating System: MacOS and Windows
  • .csharpierrc Settings: -
  • .editorconfig Settings: -

Steps to reproduce:
Have a broken .editorconfig in the file tree, run format.

Expected behavior:
Not sure, my current best idea is to ignore broken .editorconfig files with a warning.
In my case the file is installed by npm, so I cannot simply fix or remove it.
Also, the current exception does not provide the broken config location, only the repo root folder name.

Actual behavior:

❯ dotnet csharpier .                                                                                                 
Error Failure parsing editorconfig files for <edited>
  Unknown file format. Couldn't parse the line: 'View'. while parsing line number 0 with value '' - IniParser version: 2.5.2.0 while parsing line number 16 with value 'View' - IniParser version: 2.5.2.0
     at IniParser.Parser.IniDataParser.Parse(String iniDataString)
     at IniParser.StreamIniDataParser.ReadData(StreamReader reader)
     at CSharpier.Cli.EditorConfig.ConfigFileParser.Parse(String filePath, IFileSystem fileSystem) in /home/runner/work/csharpier/csharpier/Src/CSharpier.Cli/EditorConfig/ConfigFileParser.cs:line 30
     at CSharpier.Cli.EditorConfig.EditorConfigParser.ParseConfigFiles(String directoryPath, IFileSystem fileSystem)+MoveNext() in /home/runner/work/csharpier/csharpier/Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs:line 85
     at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source, Int32& length)
     at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
     at System.Linq.Enumerable.ReverseIterator`1.MoveNext()
     at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToList()
     at CSharpier.Cli.EditorConfig.EditorConfigParser.FindSections(String filePath, IFileSystem fileSystem) in /home/runner/work/csharpier/csharpier/Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs:line 68
     at CSharpier.Cli.EditorConfig.EditorConfigParser.<>c__DisplayClass0_0.<FindForDirectoryName>b__1(IFileInfo o) in /home/runner/work/csharpier/csharpier/Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs:line 56
     at System.Linq.Enumerable.SelectListIterator`2.Fill(ReadOnlySpan`1 source, Span`1 destination, Func`2 func)
     at System.Linq.Enumerable.SelectListIterator`2.ToArray()
     at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
     at System.Linq.OrderedEnumerable`1.ToList()
     at CSharpier.Cli.EditorConfig.EditorConfigParser.FindForDirectoryName(String directoryName, IFileSystem fileSystem, Boolean limitEditorConfigSearch, IgnoreFile ignoreFile) in /home/runner/work/csharpier/csharpier/Src/CSharpier.Cli/EditorConfig/EditorConfigParser.cs:line 53
     at CSharpier.Cli.Options.OptionsProvider.Create(String directoryName, String configPath, IFileSystem fileSystem, ILogger logger, CancellationToken cancellationToken, Boolean limitEditorConfigSearch) in /home/runner/work/csharpier/csharpier/Src/CSharpier.Cli/Options/OptionsProvider.cs:line 56

Formatted 0 files in 1872ms.

The file that causes the exception is in a directory without any C# files, installed by a third-party JS module.

cat Frontend/scheduleboard/node_modules/worker-farm/.editorconfig
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.js]
max_line_length = 80
View
@belav
Copy link
Owner

belav commented Apr 16, 2024

As a workaround, you can tell csharpier to ignore the bad editorconfig in the .csharpierignore file. I think this should be fairly straightforward to fix though.

@belav belav added this to the 0.28.1 milestone Apr 16, 2024
belav added a commit that referenced this issue Apr 16, 2024
belav added a commit that referenced this issue Apr 16, 2024
@belav belav closed this as completed in 2d5c87f Apr 16, 2024
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 a pull request may close this issue.

2 participants