-
Notifications
You must be signed in to change notification settings - Fork 1
ci: demo Checkstyle in static analysis #478
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,80 +38,80 @@ | |
| */ | ||
| @Component(immediate = true) | ||
| public class JavascriptModuleListener implements BundleListener { | ||
| private static final Logger logger = LoggerFactory.getLogger(JavascriptModuleListener.class); | ||
| private GraalVMEngine engine; | ||
| private final Queue<Registrar> registrars = new ConcurrentLinkedQueue<>(); | ||
|
|
||
| @Reference(cardinality = ReferenceCardinality.MANDATORY) | ||
| public void setEngine(GraalVMEngine engine) { | ||
| this.engine = engine; | ||
| } | ||
|
|
||
| @Reference(service = Registrar.class, policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE, policyOption = ReferencePolicyOption.GREEDY) | ||
| public void addRegistrar(Registrar registrar) { | ||
| for (Bundle bundle : getJavascriptModules()) { | ||
| registrar.register(bundle); | ||
| } | ||
|
|
||
| registrars.add(registrar); | ||
| } | ||
|
|
||
| public void removeRegistrar(Registrar registrar) { | ||
| registrars.remove(registrar); | ||
|
|
||
| for (Bundle bundle : getJavascriptModules()) { | ||
| registrar.unregister(bundle); | ||
| } | ||
| } | ||
|
|
||
| @Activate | ||
| public void activate(BundleContext context) { | ||
| for (Bundle bundle : getJavascriptModules()) { | ||
| engine.enableJavascriptModule(bundle); | ||
| } | ||
|
|
||
| context.addBundleListener(this); | ||
| } | ||
|
|
||
| @Deactivate | ||
| public void deactivate(BundleContext context) { | ||
| context.removeBundleListener(this); | ||
|
|
||
| for (Bundle bundle : getJavascriptModules()) { | ||
| engine.disableJavascriptModule(bundle); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void bundleChanged(BundleEvent event) { | ||
| try { | ||
| Bundle bundle = event.getBundle(); | ||
| if (isJavascriptModule(bundle)) { | ||
| if (event.getType() == BundleEvent.STARTED) { | ||
| engine.enableJavascriptModule(bundle); | ||
| for (Registrar registrar : registrars) { | ||
| registrar.register(bundle); | ||
| } | ||
| } else if (event.getType() == BundleEvent.STOPPED) { | ||
| for (Registrar registrar : registrars) { | ||
| registrar.unregister(bundle); | ||
| } | ||
| engine.disableJavascriptModule(bundle); | ||
| } | ||
| } | ||
| } catch (Exception e) { | ||
| logger.error("Cannot handle event {}", event.toString(), e); | ||
| } | ||
| } | ||
|
|
||
| public List<Bundle> getJavascriptModules() { | ||
| return Arrays.stream(engine.getBundleContext().getBundles()) | ||
| .filter(bundle -> bundle.getState() == Bundle.ACTIVE && isJavascriptModule(bundle)) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
|
||
| public boolean isJavascriptModule(Bundle bundle) { | ||
| return bundle.getBundleId() != engine.getBundleContext().getBundle().getBundleId() && | ||
| bundle.getHeaders().get(BUNDLE_HEADER_JAVASCRIPT_INIT_SCRIPT) != null; | ||
| } | ||
| private static final Logger logger = LoggerFactory.getLogger(JavascriptModuleListener.class); | ||
| private GraalVMEngine engine; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| private final Queue<Registrar> registrars = new ConcurrentLinkedQueue<>(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
|
|
||
| @Reference(cardinality = ReferenceCardinality.MANDATORY) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| public void setEngine(GraalVMEngine engine) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| this.engine = engine; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
|
|
||
| @Reference(service = Registrar.class, policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE, policyOption = ReferencePolicyOption.GREEDY) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| public void addRegistrar(Registrar registrar) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| for (Bundle bundle : getJavascriptModules()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| registrar.register(bundle); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
|
|
||
| registrars.add(registrar); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
|
|
||
| public void removeRegistrar(Registrar registrar) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| registrars.remove(registrar); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
|
|
||
| for (Bundle bundle : getJavascriptModules()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| registrar.unregister(bundle); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
|
|
||
| @Activate | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| public void activate(BundleContext context) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| for (Bundle bundle : getJavascriptModules()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| engine.enableJavascriptModule(bundle); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
|
|
||
| context.addBundleListener(this); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
|
|
||
| @Deactivate | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| public void deactivate(BundleContext context) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
| context.removeBundleListener(this); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶 |
||
|
|
||
| for (Bundle bundle : getJavascriptModules()) { | ||
| engine.disableJavascriptModule(bundle); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void bundleChanged(BundleEvent event) { | ||
| try { | ||
| Bundle bundle = event.getBundle(); | ||
| if (isJavascriptModule(bundle)) { | ||
| if (event.getType() == BundleEvent.STARTED) { | ||
| engine.enableJavascriptModule(bundle); | ||
| for (Registrar registrar : registrars) { | ||
| registrar.register(bundle); | ||
| } | ||
| } else if (event.getType() == BundleEvent.STOPPED) { | ||
| for (Registrar registrar : registrars) { | ||
| registrar.unregister(bundle); | ||
| } | ||
| engine.disableJavascriptModule(bundle); | ||
| } | ||
| } | ||
| } catch (Exception e) { | ||
| logger.error("Cannot handle event {}", event.toString(), e); | ||
| } | ||
| } | ||
|
|
||
| public List<Bundle> getJavascriptModules() { | ||
| return Arrays.stream(engine.getBundleContext().getBundles()) | ||
| .filter(bundle -> bundle.getState() == Bundle.ACTIVE && isJavascriptModule(bundle)) | ||
| .collect(Collectors.toList()); | ||
| } | ||
|
|
||
| public boolean isJavascriptModule(Bundle bundle) { | ||
| return bundle.getBundleId() != engine.getBundleContext().getBundle().getBundleId() && | ||
| bundle.getHeaders().get(BUNDLE_HEADER_JAVASCRIPT_INIT_SCRIPT) != null; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,9 +116,8 @@ else if (packageRelativePath.equals("settings/template-thumbnail.png")) { | |
| jos.putNextEntry(new ZipEntry("images/template-preview/" + StringUtils.substringAfter(packageRelativePath, "settings/"))); | ||
| } | ||
| // Map everything else in settings/ to META-INF/ | ||
| else { | ||
| else | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck> reported by reviewdog 🐶 |
||
| jos.putNextEntry(new ZipEntry("META-INF/" + StringUtils.substringAfter(packageRelativePath, "settings/"))); | ||
| } | ||
| } else if (packageRelativePath.startsWith("components") && packageRelativePath.endsWith(".png")) { | ||
| String[] parts = StringUtils.split(packageRelativePath, "/"); | ||
| String nodeTypeName = parts[2]; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.