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

UnusedImport false positive when enum abstract var is using #523

Open
T1mL3arn opened this issue May 24, 2023 · 1 comment
Open

UnusedImport false positive when enum abstract var is using #523

T1mL3arn opened this issue May 24, 2023 · 1 comment

Comments

@T1mL3arn
Copy link

Example

// file BaseMenu.hx
package menu;

enum abstract MenuCommand(String) to String {
	var EXIT_GAME;
}

// file Main.hx
import menu.BaseMenu.MenuCommand;

var abc = '123';
switch (abc) {
  case EXIT_GAME:  trace('exit');
  default: 0;
}

gives UnusedImport - Unused import "menu.BaseMenu.MenuCommand" detected.

If I change case EXIT_GAME to case MenuCommand.EXIT_GAME there is no detection, so I guess checkstyle does not know EXIT_GAME is from MenuCommand (though in vscode really unused imports are grayed-out).

@AlexHaxe
Copy link
Member

there's not much checkstyle can do here. vscode can gray out those imports because of languageserver - and diagnostics from Haxe compiler telling it to. checkstyle doesn't have that source of information. so it cannot make that connection.

your sample is also flawed, since you just assign a string to abc and then use it to switch over fields of an unrelated enum abstract. if you wanted to profit from exhaustiveness checks you would need to declare var abc:MenuCommand and then everything would be fine.

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

No branches or pull requests

2 participants