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

Fix Xtend warnings #4578

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

holgerfriedrich
Copy link
Member

@holgerfriedrich holgerfriedrich commented Jan 26, 2025

  1. Remove unused imports and unnecessary private modifiers
  2. Use === when comparing to null
  3. Replace deprecated methods (initializeLater)

During the mvn phase generate-sources, we have had around 70 warnings from the Xtend generator.
This PR fixes half of the warnings of the generate phase (still the compiler has some issues with the generated code, but this is out of scope for now).

These changes seem to be safe, the generated code does not have significant changes compared to the old output.

FTR: those are the issues this PR is resolving:

[INFO] --- xtend:2.37.0:compile (default) @ org.openhab.core.model.rule ---
[WARNING] 
WARNING: 	RulesStandaloneSetup.xtend - org.openhab.core.model.rule\src\org\openhab\core\model\rule\RulesStandaloneSetup.xtend
32: The private modifier is unnecessary on field scriptServiceUtil
[WARNING] 
WARNING: 	RulesStandaloneSetup.xtend - org.openhab.core.model.rule\src\org\openhab\core\model\rule\RulesStandaloneSetup.xtend
33: The private modifier is unnecessary on field scriptEngine
[WARNING] 
WARNING: 	RulesJvmModelInferrer.xtend - org.openhab.core.model.rule\src\org\openhab\core\model\rule\jvmmodel\RulesJvmModelInferrer.xtend
43: The import 'org.openhab.core.events.Event' is never used.
[WARNING] 
WARNING: 	RulesJvmModelInferrer.xtend - org.openhab.core.model.rule\src\org\openhab\core\model\rule\jvmmodel\RulesJvmModelInferrer.xtend
20: The import 'org.openhab.core.thing.events.ChannelTriggeredEvent' is never used.
[WARNING] 
WARNING: 	RulesJvmModelInferrer.xtend - org.openhab.core.model.rule\src\org\openhab\core\model\rule\jvmmodel\RulesJvmModelInferrer.xtend
57: The private modifier is unnecessary on field logger
[WARNING] 
WARNING: 	RulesJvmModelInferrer.xtend - org.openhab.core.model.rule\src\org\openhab\core\model\rule\jvmmodel\RulesJvmModelInferrer.xtend
63: The extension org.eclipse.xtext.naming.IQualifiedNameProvider is not used in RulesJvmModelInferrer
[WARNING] 
WARNING: 	RulesJvmModelInferrer.xtend - org.openhab.core.model.rule\src\org\openhab\core\model\rule\jvmmodel\RulesJvmModelInferrer.xtend
85: The method initializeLater(Procedure1<? super T>) from the type IJvmDeclaredTypeAcceptor.IPostIndexingInitializing is deprecated


[INFO] --- xtend:2.37.0:compile (default) @ org.openhab.core.model.script ---
[WARNING] 
WARNING: 	ScriptJvmModelInferrer.xtend - org.openhab.core.model.script\src\org\openhab\core\model\script\jvmmodel\ScriptJvmModelInferrer.xtend
28: The import 'org.openhab.core.events.Event' is never used.
[WARNING] 
WARNING: 	ScriptJvmModelInferrer.xtend - org.openhab.core.model.script\src\org\openhab\core\model\script\jvmmodel\ScriptJvmModelInferrer.xtend
42: The private modifier is unnecessary on field logger
[WARNING] 
WARNING: 	ScriptJvmModelInferrer.xtend - org.openhab.core.model.script\src\org\openhab\core\model\script\jvmmodel\ScriptJvmModelInferrer.xtend
109: The method initializeLater(Procedure1<? super T>) from the type IJvmDeclaredTypeAcceptor.IPostIndexingInitializing is deprecated
[WARNING] 
WARNING: 	ScriptStandaloneSetup.xtend - org.openhab.core.model.script\src\org\openhab\core\model\script\ScriptStandaloneSetup.xtend
30: The private modifier is unnecessary on field scriptServiceUtil
[WARNING] 
WARNING: 	ScriptStandaloneSetup.xtend - org.openhab.core.model.script\src\org\openhab\core\model\script\ScriptStandaloneSetup.xtend
31: The private modifier is unnecessary on field scriptEngine
[WARNING] 
WARNING: 	ScriptInterpreter.xtend - org.openhab.core.model.script\src\org\openhab\core\model\script\interpreter\ScriptInterpreter.xtend
49: The public modifier is unnecessary on class ScriptInterpreter
[WARNING] 
WARNING: 	ScriptInterpreter.xtend - org.openhab.core.model.script\src\org\openhab\core\model\script\interpreter\ScriptInterpreter.xtend
58: The private modifier is unnecessary on field typeResolver
[WARNING] 
WARNING: 	ScriptInterpreter.xtend - org.openhab.core.model.script\src\org\openhab\core\model\script\interpreter\ScriptInterpreter.xtend
133: The operator '!=' should be replaced by '!==' when null is one of the arguments.
[WARNING] 
WARNING: 	ScriptInterpreter.xtend - org.openhab.core.model.script\src\org\openhab\core\model\script\interpreter\ScriptInterpreter.xtend
145: Unnecessary cast from QuantityLiteral to QuantityLiteral



[INFO] --- xtend:2.37.0:compile (default) @ org.openhab.core.model.thing ---
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
28: The import 'org.openhab.core.common.registry.AbstractProvider' is never used.
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
31: The import 'org.openhab.core.service.ReadyMarkerFilter' is never used.
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
80: The private modifier is unnecessary on field XML_THING_TYPE
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
82: The private modifier is unnecessary on field localeProvider
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
84: The private modifier is unnecessary on field modelRepository
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
86: The private modifier is unnecessary on field thingTypeRegistry
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
87: The private modifier is unnecessary on field channelTypeRegistry
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
89: The private modifier is unnecessary on field bundleResolver
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
91: The private modifier is unnecessary on field thingsMap
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
93: The private modifier is unnecessary on field thingHandlerFactories
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
95: The private modifier is unnecessary on field configDescriptionRegistry
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
97: The private modifier is unnecessary on field queue
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
98: The private modifier is unnecessary on field lazyRetryThread
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
100: The private modifier is unnecessary on field logger
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
102: The private modifier is unnecessary on field loadedXmlThingTypes
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
104: The private modifier is unnecessary on field modelLoaded
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
141: The operator '==' should be replaced by '===' when null is one of the arguments.
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
605: The operator '==' should be replaced by '===' when null is one of the arguments.
[WARNING] 
WARNING: 	GenericThingProvider.xtend - org.openhab.core.model.thing\src\org\openhab\core\model\thing\internal\GenericThingProvider.xtend
636: The private modifier is unnecessary on field lazyRetryRunnable

@holgerfriedrich holgerfriedrich marked this pull request as ready for review January 26, 2025 23:47
@holgerfriedrich holgerfriedrich requested a review from a team as a code owner January 26, 2025 23:47
@holgerfriedrich holgerfriedrich marked this pull request as draft January 27, 2025 06:58
* Remove unused imports and unnecessary private modifiers
* Use === when comparing to null

Signed-off-by: Holger Friedrich <[email protected]>
* Replace deprecated initializeLater

Signed-off-by: Holger Friedrich <[email protected]>
@holgerfriedrich
Copy link
Member Author

holgerfriedrich commented Feb 1, 2025

This PR does not yet address one specific type of warning which occurs ~30 times:

 [WARNING] 
WARNING: 	ScriptJvmModelInferrer.xtend - org.openhab.core.model.script\src\org\openhab\core\model\script\jvmmodel\ScriptJvmModelInferrer.xtend
166: The method newTypeRef(EObject, Class<?>, JvmTypeReference...) from the type JvmTypesBuilder is deprecated

I tried injecting JvmTypeReference in ScriptJvmModelInferrer.xtend, and using typeRef().
It does not work properly, "openHAB Core :: Integration Tests :: Model Script Tests" fail with this modification.

Any hint how to approach this is welcome.

@holgerfriedrich holgerfriedrich marked this pull request as ready for review February 1, 2025 10:36
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.

1 participant