Skip to content

Can't get rid of 'Name source files using lowercase_with_underscores.dart(file_names)' #3236

Closed

Description

@Asperson

Hi all, love what you doing.

Yesterday renamed one of my widgets from tracking_sheet.dart to Measure_sheet.dart. Of course got warning, immediately renamed it to measure_sheet.dart, but warning didn't go away.

Renamed it to Kmeasure_sheet.dart, then back to measure_sheet.dart, the warning appeared again:
warning

I tried also removing file from the project and re-adding - no luck.
Please help how can I kill the warning.

Best regards,
Dmitry

Activity

  1. DanTup commented on Mar 29, 2021

    @DanTup
    Member

    I'm not able to reproduce this, the error disappears once I rename the file back. In the logs I can see the server sending an update to clear them.

    Could you try capturing a log?

    • Open your project and wait for analysis to finish
    • Run the Dart: Capture Analysis Server Logs command from the command palette
    • Rename the file to trigger the error
    • Rename the file back and wait a few seconds
    • Click the Cancel button on the logging notification to stop logging and open the log file

    Note: The log file may include parts of your source code so it would be better to reproduce on a small sample project, but otherwise be sure to check the log for anything sensitive before sharing.

    Thanks!

  2. added
    awaiting infoRequires more information from the customer to progress
    on Mar 29, 2021
  3. Asperson commented on Mar 29, 2021

    @Asperson
    Author

    I was able to reproduce it on a small project, copying and reducing existing measure_sheet.dart.
    One note - I renamed file in the vscode using F2 in the project tree, not externally.
    After vscode loaded the file looked correctly but then if I click another file and return back to this one it become reported having incorrect cases in its name.

    Dart-Code-Log-2021-02-01 11-38-48.txt

    vscode v1.54.3 (user setup)
    dart-code v3.20.1

  4. DanTup commented on Mar 29, 2021

    @DanTup
    Member

    Strange - I renamed the same way, though no luck. I tried on Windows too but it seemed fine (I tried both changing only the casing, and also changing the casing and adding more letters at the same time).

    Can you confirm exactly what sort of rename you're making? If I can't repro, I'll see if I can trace through the server how this is normally handled to see if I can come up with any theories for why it wouldn't be happening for you.

    Thanks!

  5. Asperson commented on Mar 30, 2021

    @Asperson
    Author

    I think I found the way to reproduce bug:

    1. create flutter new app with 'flutter create'
    2. copy attached files to the new project, pubspec.yaml, analysis_options.yaml and aa_aa.dart, last one to lib folder.
    3. get packages
    4. set MyApp.home to AaWidget()
    5. close vscode and open it again
    6. rename aa_aa.dart in vscode by F2 to Bb_aa.dart, say 'yes' to allow extension Dart to make refactoring changes
    7. rename it again the same way to bb_aa.dart

    After these steps on my machine (windows 10) all content in bb_aa.dart undercrossed with blue line and Problem window shows a case problem for Bb_aa.dart file

    add2project.zip

  6. cto-leaps commented on Apr 11, 2021

    @cto-leaps

    I have the same issue on Mac OS, but the error is only shown whenever I make any change to the file and remains until I save the file again. Then it disappears. Makes it hard to edit a file...

  7. DanTup commented on Apr 12, 2021

    @DanTup
    Member

    but the error is only shown whenever I make any change to the file and remains until I save the file again

    Aha! I couldn't repro with the instructions above, but when I modified the file the error appeared again. I'll do some digging. Thanks!

  8. DanTup commented on Apr 12, 2021

    @DanTup
    Member

    Also - after restarting VS Code I could repro it the original way - just renaming the file to Bb and then back to bb - the error remained.

  9. DanTup commented on Apr 12, 2021

    @DanTup
    Member

    This feels like a VS Code bug. When I change the casing of a file, then reload VS Code, then close and re-open the file, VS Code still keeps giving me the old case - even though it shows the new casing in its UI.

    I've opened microsoft/vscode#121106 to get some clarification (but it's not clear based on microsoft/vscode#102627 whether this is intended or not).

  10. added
    in editorRelates to code editing or language features
    and removed
    awaiting infoRequires more information from the customer to progress
    on Apr 12, 2021
  11. added this to the On Deck milestone on Apr 12, 2021
  12. 48 remaining items

  13. Omi231 commented on Aug 12, 2022

    @Omi231

    deleting User/workspaceStorage inside (C:\Users*USERNAME*\AppData\Roaming\Code) worked for me.

  14. jaidex commented on Aug 16, 2022

    @jaidex

    I've found evidence that this may be related to an unchanged reference to the old file name in another file (in and import).

    • I was getting the error, went through the steps of removing the file, creating a new one, and populating it with the original file's contents.
    • When I saved this version, I got an error on an import that had the old version of the file name (with caps included).
    • I changed the name in the import and the error went away.

    Note: to do this, I DID first follow the standard clean-up steps as stated above, however, the fact that it exposed the usage of the original, caps-included name which had been renamed a LONG time previously, makes me think there's a related issue there.

    As long as the original file had not been physically removed from the project and replaced with an old one, the import with the pre-changed name was still working, though the name was NOT the same.

  15. DanTup commented on Aug 22, 2022

    @DanTup
    Member

    @jaidex are you able to reproduce that issue? I can't think of a reason why a mismatched import would trigger this issue (although I can imagine it could cause some other issues while running/debugging). If you can reproduce it, or if the dart.normalizeFileCasing setting doesn't prevent it, I'd definitely like to understand why it's failing.

    Thanks!

  16. Lorenzohidalgo commented on Oct 7, 2022

    @Lorenzohidalgo

    The version with this fix in actually shipped last week. See https://dartcode.org/releases/v3-27/#editor :-)

    @DanTup it looks like this issue has "re-surfaced" at least in our case.

    Here are the versions we are working with that show the incorrect warning:
    Flutter: v3.3.3
    Dart: v2.18.2
    VSCode: v1.72.0
    Dart Code Extension: v3.50.0

  17. DanTup commented on Oct 7, 2022

    @DanTup
    Member

    @Lorenzohidalgo do you have the dart.normalizeFileCasing setting enabled? If so, can you capture a log as described in this comment above? Thanks!

  18. Lorenzohidalgo commented on Oct 7, 2022

    @Lorenzohidalgo

    @DanTup sorry, I didn't have that config initially enabled.
    I've reproduced the steps mentioned in the linked comment but could not reproduce our error with either dart.normalizeFileCasing set to selected or unselected.

    In our case, this issue happened initially on my colleague's system and "passed" on to me when I pulled the changes. There was no "file name change" happening on my computer and I can only dismiss the warning by adding // ignore_for_file: file_names to the files.

    I'll try to reproduce all steps again while capturing the logs. Since the "use case"/issue is not precisely the same, should I share them on this issue or create a new one?

  19. DanTup commented on Oct 7, 2022

    @DanTup
    Member

    @Lorenzohidalgo do you mean the issue has gone away now and you can no longer reproduce?

    If you can reproduce an issue with normalizeFileCasing enabled, please do file a new issue. normalizeFileCasing is a bit of a hack and not the real solution, but it's all we have right now. Unfortunately the real fix is rather complicated because it requires VS Code, LSP and the Dart server to all agree on how case sensitivity should work, but right now VS Code is basing its case sensitivity purely on platform (which is not always correct, and makes it perhaps not a great model for LSP/language servers to follow).

  20. deleted a comment from ho-lapang on Oct 10, 2022
  21. PeterHenter commented on Jan 29, 2023

    @PeterHenter

    I had the same issue.

    My versions are as follows:
    Flutter 3.7.0,
    Dart is 2.19.0
    Visual Studio Code 1.74.3
    VSC Flutter extension v3.58.0
    VSC Dart extension v3.58.0

    What I noticed is, that only 1 file was affected in the entire project. The file was originally called Buttons.dart. After renaming the file in the VSC Explorer pane to buttons.dart the file name changed in the Explorer pane but remained the same on tab in the Editor, and the linter kept complaining.

    I managed to fix the issue by inserting an underscore at a random location in the file name, like button_s.dart. After this the warning disappeared. I then closed VSC, then reopened it, and renamed the file again back to buttons.dart. And the warning did not come back.

  22. DanTup commented on Jan 30, 2023

    @DanTup
    Member

    I managed to fix the issue by inserting an underscore at a random location in the file name, like button_s.dart. After this the warning disappeared. I then closed VSC, then reopened it, and renamed the file again back to buttons.dart. And the warning did not come back.

    Ah, that's good to know. My guess is when you make a change to the filename that is more than just casing, then VS Code does change the internal model, which removes the old casing. Renaming only by the case likely does not. If it works reliably, this might be a better workaround than using normalizeFileCasing since that introduces a small performance penalty.

  23. sanba-anass commented on Sep 30, 2024

    @sanba-anass

    issue presist it's annoying since i'm using code gen with mobx and i'm getting an error saying unmatching file of 'part' and 'part of ' even i f i rename it to the correct file naming convention so odd

  24. BlarCkat commented on Oct 1, 2024

    @BlarCkat

    @sanba-anass can you take a screenshot of the problem?

  25. DanTup commented on Oct 1, 2024

    @DanTup
    Member

    @sanba-anass that sounds like a different issue, but it's hard to diagnose without seeing the code. Feel free to open a new issue including a sample project or screenshots that show both of the files in question and the error you're seeing and I'll try to help. Thanks!

  26. larssn commented on Mar 30, 2025

    @larssn

    I managed to fix the issue by inserting an underscore at a random location in the file name, like button_s.dart. After this the warning disappeared. I then closed VSC, then reopened it, and renamed the file again back to buttons.dart. And the warning did not come back.

    FYI this issue still exists, but managed to fix it with the above workaround.

  27. hosmoon commented on Apr 30, 2025

    @hosmoon

    저도 같은 문제가 있었습니다.

    내 버전은 다음과 같습니다: Flutter 3.7.0, Dart는 2.19.0 Visual Studio Code 1.74.3 VSC Flutter 확장 프로그램 v3.58.0 VSC Dart 확장 프로그램 v3.58.0

    제가 발견한 것은 전체 프로젝트에서 단 하나의 파일만 영향을 받았다는 것입니다. 원래 이름은 Buttons.dart. VSC 탐색기 창에서 파일 이름을 . 로 변경한 후 탐색기 buttons.dart창에서는 파일 이름이 변경되었지만 편집기 탭에는 그대로 남아 있었고, 린터는 계속 문제를 일으켰습니다.

    파일 이름에 임의의 위치(예: .)에 밑줄을 삽입하여 문제를 해결했습니다 button_s.dart. 그 후 경고가 사라졌습니다. VSC를 닫았다가 다시 열어 파일 이름을 .으로 다시 변경했습니다 buttons.dart. 그러자 경고가 다시 나타나지 않았습니다.

    I love you.
    I solve that problem as add _ method.
    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresis bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions