SonarQube: How to suppress a warning in Kotlin code - kotlin

I'm using SQ 7.3-alpha1 with sonar-kotlin-plugin-1.0.1.965.jar. However, I cannot deactivate a special warning inside my Kotlin code for repositories in Spring Data where I need an "_" in a method name.
I tried both //NOSONAR and #Suppress("kotlin:S100") and #SuppressWarnings("kotlin:S100"). Any hint is appreciated.

You're not able to deactivate that issue because none of the mechanisms you're trying to use have been implemented for Kotlin.
Instead, you'll have to do this from the UI side.

Great news, https://jira.sonarsource.com/browse/SONARSLANG-373 is fixed in version 1.6 of Sonarslang. So an update to that version might improve the situation. I’ve not tested it yet, hence the cautious wording.

Related

jetty runner plugin for IntelliJ Idea install error

I'm using Intellij Idea 2022.2.3, while I wanna use jetty runner, the lastest jetty version is 1.4.20, and I got an error as below:
com.intellij.diagnostic.PluginException: The default implementation of method 'getId' is deprecated, you need to override it in 'class com.github.guikeller.jettyrunner.conf.JettyRunnerConfigurationFactory'. The default implementation delegates to 'getName' which may be localized, but return value of this method must not depend on current localization. [Plugin: JettyRunner-GK]
at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:23)
at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:83)
at com.intellij.diagnostic.PluginException.reportDeprecatedDefault(PluginException.java:110)
at com.intellij.execution.configurations.ConfigurationFactory.getId(ConfigurationFactory.java:75)
at com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl.writeExternal(RunnerAndConfigurationSettingsImpl.kt:265)
at com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl.writeScheme(RunnerAndConfigurationSettingsImpl.kt:321)
at com.intellij.configurationStore.LazySchemeProcessor.writeScheme(scheme-impl.kt:65)
at com.intellij.execution.impl.RunConfigurationSchemeManager.writeScheme(RunConfigurationSchemeManager.kt:121)
at com.intellij.execution.impl.RunConfigurationSchemeManager.writeScheme(RunConfigurationSchemeManager.kt:21)
at com.intellij.configurationStore.schemeManager.SchemeManagerImpl.saveScheme(SchemeManagerImpl.kt:393)
at com.intellij.configurationStore.schemeManager.SchemeManagerImpl.save(SchemeManagerImpl.kt:333)
at com.intellij.configurationStore.Scheme_implKt.save(scheme-impl.kt:164)
at com.intellij.execution.impl.RunManagerImpl.getState(RunManagerImpl.kt:643)
at com.intellij.execution.impl.RunManagerImpl.getState(RunManagerImpl.kt:78)
at com.intellij.configurationStore.ComponentStoreImpl.commitComponent(ComponentStoreImpl.kt:334)
at com.intellij.configurationStore.ComponentStoreImpl.commitComponents$intellij_platform_configurationStore_impl(ComponentStoreImpl.kt:240)
at com.intellij.configurationStore.ComponentStoreWithExtraComponents.commitComponents$intellij_platform_configurationStore_impl(ComponentStoreWithExtraComponents.kt:94)
at com.intellij.configurationStore.ComponentStoreImpl$commitComponentsOnEdt$$inlined$withEdtContext$intellij_platform_configurationStore_impl$1.invokeSuspend(ComponentStoreImpl.kt:723)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at com.intellij.openapi.application.constraints.BaseConstrainedExecution$Companion$scheduleWithinConstraints$1.invoke(BaseConstrainedExecution.kt:68)
at com.intellij.openapi.application.constraints.BaseConstrainedExecution$Companion.scheduleWithinConstraints(BaseConstrainedExecution.kt:71)
at com.intellij.openapi.application.constraints.BaseConstrainedExecution.scheduleWithinConstraints(BaseConstrainedExecution.kt:38)
at com.intellij.openapi.application.impl.BaseExpirableExecutorMixinImpl.access$scheduleWithinConstraints$s1153900543(BaseExpirableExecutorMixinImpl.kt:12)
at com.intellij.openapi.application.impl.BaseExpirableExecutorMixinImpl$scheduleWithinConstraints$$inlined$Runnable$1.run(Runnable.kt:19)
at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:209)
at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:21)
at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:191)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)
at com.intellij.openapi.application.impl.ApplicationImpl$3.run(ApplicationImpl.java:513)
at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:75)
at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:118)
at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:42)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:779)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:730)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:724)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:749)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:918)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:766)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:450)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:791)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:449)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:624)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:447)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:493)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
It looks like that plugin is out of date with your version of Intellij. It seems like the plugin has not been updated recently and is looking for a new maintainer.
You could
fork it and make the changes suggested in the error message (it doesn't seem like it would be too complicated)
Downgrade your intellij - probably a bad idea, but if you are really in a pinch might be the fastest way to get past this
Find an alternate solution; perhaps use the jetty maven plugin which appears to be still supported and has easy commands to run jetty (which can be put into an intellij run configuration)
I would recommend the last way. If you are already using maven, it will be pretty easy. If you are not using maven then it is a good opportunity to learn how to use it as it is very helpful for managing java projects
Although I am looking for a new maintainer I still am maintaining the plugin.
Please raise an issue on GitHub so this can be fixed, cheers!
Project link: https://github.com/guikeller/jetty-runner
PS: raised an issue on your behalf:
https://github.com/guikeller/jetty-runner/issues/81

How is Groovy hot-swap agent "gragent.jar" is supposed to work in Intellij Idea?

It seems doesn't add anything to the regular java hot-swapping. I'd like to get the groovy class hot-swapped in a case of method adding/removing/signature changing. Is it possible with this agent?
Dany's answer is correct, but doesn't answer the question fully. No, this agent doesn't help you to hot-swap when fields or methods are changed. You might want to consider using DCEVM for that.
Removes all timestamp-related Groovy fields on class loading
Also clears Groovy's call site cache
As stated in
https://github.com/JetBrains/intellij-community/blob/master/plugins/groovy/hotswap/agentSrc/org/groovy/debug/hotswap/ResetAgent.java

Patch Gecko to introduce a synonym for a supported CSS property ("appearance" for "-moz-appearance")

I am working on a firefox fork and would like to duplicate -moz-apperance as appearance. I have tried duplicating it as a shorthand property but this throws errors at the compile stage using ./mach build The documentation seems cryptic.
There's documentation about implementing new CSS properties, which might be hard to follow, but browsers are complex pieces of software.
(Currently this question is too broad to provide an answer that's not link-only.)
update: an actual answer from dbaron (via mozilla.dev.platform):
by adding entries to:
https://mxr.mozilla.org/mozilla-central/source/layout/style/nsCSSPropAliasList.h

"Guess" method arguments in IntelliJ IDEA

Eclipse has a feature, where it "guesses" arguments for a method call, based on types (and probably variable names?). Is there an equivalent in IntelliJ? I know Smart Complete should be capable of completing multiple arguments, but it doesn't work as good (especially when there is more than one String argument for example).
EDIT: It's called "Insered best guessed arguments" in Eclipse.
There is Ctrl+Shift+Space (Smart-Type, I think), but as of this writing, it's crap and doesn't go the whole hog.
Despite being an Eclipse fan, I've always openly acknowledge that if Eclipse can do it, IntelliJ can probably do it better... not this time, how dissappointing q(`_`!)p
IDEA doesn't support it, see the related feature request.
Try
(Ctrl+P) for Windows/Linux
Or
(Cmd+P) for OS X
this lists you the parameters for a method.
If you can accept a very basic low tech version of this, you could try this Gist
https://gist.github.com/kontext-e/f68c6a1b90dd862afb5d
for IDEAs LivePlugin.
Please ping me if there is some interest that I should make a real plugin out of this.

Updating to PHP 5.3 with deprecated functions warning disabled

I'm very keen to update a number of our servers to PHP 5.3. This would be in readiness for Zend Framework 2 and also for the apparent performance updates. Unfortunately, i have large amounts of legacy code on these servers which in time will be fixed, but cannot all be fixed before the migration. I'm considering updating but disabling the deprecated function error on all but a few development sites where i can begin to work through updating old code.
error_reporting(E_ALL ^ E_DEPRECATED);
Is there any fundamental reason why this would be a bad idea?
Well, you could forget that you set the flag and wonder why your application breaks in a next PHP update. It can be very frustrating to debug an application without proper error reporting. That's one reason I can think of.
However, if you do it, document it somewhere. It can save you a couple of hours before you remember setting the flag at all.
If you haven't already you should read the migration guide with particular focus on Backward Incompatible Changes and Removed Extensions.
You have bigger issues than deprecation. Ignoring E_DEPRECATED will not suffice. Because of the incompatible changes there will also be other type of errors or, maybe, even worse, unexpected behaviors.
Here's a simple example:
<?php
function goto($line){
echo $line;
}
goto(7);
?>
This code will work fine and output 7 in PHP 5.2.x but will give you a parse error in PHP 5.3.x.
What you need to do is take each item in that guide and check your code and update where needed. To make this faster you could ignore the deprecated functionality in a first phase and just disable error reporting for E_DEPRECATED, but you can't assume that you will only get some harmless warnings when porting to another major PHP branch.
Also don't forget about your hack and fix the deprecated issues as soon as possible.
Regards,
Alin
Note: I tried to answer the question from a practical point of view, so please don't tell me that ignoring warnings is bad. I know that, but I also know that time is not an infinite resource.
I presume you have some kind of test server? If not, you really should set one up and test your code in PHP 5.3. If your code is thoroughly Unit Tested, testing it will take seconds, and fixing it will be fairly quick too, as the unit tests will tell you exactly where to look. If not, then consider making Unit Testing it all a priority before the next release, and in the meantime go through it all, first with E_DEPRECATED warnings disabled and fix anything which comes up, then with it re-enabled once you have time. You could also run a global find-and-replace for easier to fix errors.