Intellij ignorance on .kt files under package structure having no 'package ..' statement? WHY? - intellij-idea

package com.yada.yada
What happens with IntelliJ when I create Java class 'ss' in com.yada.yada without package statement? - RED "Missing Package Statement".
What happens when I create Kotlin file in com.yada.yada without package statement? - "Keep going bro until your DI framework will fail to scan your deps during runtime"
Why IJ package validation is non-mandatory for Kotlin? I just wasted an hour trying to figure out what's wrong with package scan only to realise this was the show stopper. Would Java 9 jigsaw quadruple the chaos for Kotlin sparked by such malformed files/classes with no warning messages? Well, you bet it will!
Please return back the "warning" statement for Kotlin. P.S. registration/login methods are not sufficient for myself to access Intellij bugtracker(and I am genuinely pissed off with one time access password resets, 1000 resources and 980 passwords I don't remember or care to) therefore making this public on stackoverflow.
If anybody going to defend this behaviour please explain why? Maybe I am missing something, otherwise please reply with open bug(preferably somebody from JetBrains) and I will accept it.

The missing inspection warning for files with no package statement is a bug; the corresponding YouTrack issue is here.

I'm not sure this post is appropriate here, but to answer the actual question, the official documentation states that:
If the package is not specified, the contents of such a file belong to
"default" package that has no name.
Since with Kotlin your files don't have to be in folders that match their packages, not having a package declaration has to be an option so that you can have files that are organized in folders, but you don't wish to put them in packages - this way they can have the same package as if they weren't nested in any folders, and were just in the root of the project.
I do concede that it's a bit odd there is a warning for your package declaration not matching the folder your file is in, but you don't get this if you just omit the package declaration altogether. I suppose this is assumed to be intentional.
This shouldn't generally be a problem because IDEs will generate the appropriate package declaration for the folder you've created your file in by default. I'm not sure how you created a file without a package declaration if you're using IntelliJ, unless you did it in the root src folder instead of inside a package folder.

Related

Why does Kotlin allow package structure that does not match folder structure?

Kotlin packages are written package one.two.three, and they usually match the folder structure (e.g. one/two/three) of the project, but they don't have to match the folder structure. What is the motivation behind the decision to allow packages to not match the folder structure? What use cases does it enable?
The obvious use case is that now you can organize your code in whatever packages and you are not forced to have the same folder structure. Other than that I don't see any other use case. Why have they done it? Not sure and it does not seem to be something useful or wanted because the recommendation is still to match packages with the folder structure (even IntelliJ warns you when you have a package that does not match the folder structure.
It seems to me to be a feature that was not needed or even wanted by the community.

Gradle and IDEA disagree on where Kotlin source files should go

By default, IntelliJ IDEA puts Kotlin source files for package foo in src/*.kt but Gradle isn't happy with that; it can only see them if they go in src/main/kotlin/foo/*.kt.
I've tried moving them there, but now IDEA gives a warning in my source files, in the package foo line, saying 'package directive doesn't match file location' and wanting to change the package to main.kotlin.foo (which of course would be incorrect, and probably confuse Gradle again).
How do you get the two to agree on where the files should go? (Ideally I would like it to be somewhere that doesn't have any levels of empty subdirectories, but I will settle for anything the two programs can agree on.)
It turns out that if you just delete the IDEA configuration, IDEA will automatically rebuild it from the Gradle project, and thereby become happy with the Gradle default layout.

How to make IntelliJ IDEA keep package prefixes for source folders after reimport?

For some projects the standard directory layout module/src/main/scala/com/company/project/module may be an overkill and can be flattened to module/src. I work with the scala language which doesn't force packages to be equal to file paths. IDEA will be unhappy, complain that a package doesn't correspond to a file path, create new classes with wrong packages and so on. To fix that I can specify package prefix for source folders and then it will work fine. However those prefixes are lost on project reimport (from SBT). Can I make IDEA keep them?
sbt-idea plugin has ideaPackagePrefix property. See also the related feature request.
More details can be found here.

Bug in IDL parser in RedHawk IDE

Some valid IDL files, build as IDL Projects and install but some or all of their contents do not appear in the SCA Explorer/Target SDR/IDL Repository. I believe that the IDL parser used to build the tree in the IDL Repository is different from that used by the omniORB idl2cpp (omniidl) during building and it rejects some valid IDL. The cases I have found all use a value of a const previously defined. e.g.,
const Algorithm ALG_NONE = 0
const Algorithm ALG_LPC = ALG_NONE + 3
The second line can occur in the same file or in a file that includes the file containing the first line.
The file containing the first line is accepted if the second line is not in the same file, but the file containing the second line is rejected and none of its contents appear in the IDL Repository tree. It appears that it rejects a const appearing as a value on the right side of an assignment statement. These files however are valid and are accepted as valid by omniidl. But they cannot be used in RedHawk because they cannot be selected for a component interface.
I am not very familiar with RedHawk IDE sources or Eclipse plugins and so have not been able to find where the syntax for the parser is specified. I see "eclipsecorba" appearing in plugin lists so I assume that RedHawk is using the Eclipse CORBA Plugin (aka ECP) and that its parser is the one being used to build the tree. So I suspect that the parser error is in that package rather than in code added by RedHawk.
Can anyone confirm this and suggest where I might look in the ECP code for this? Should I report this as a ECP bug to the ECP group on SourceForge? I am not sure how active it is since it appears that the latest version is from 2008.
This seems to be a bug in the IDL editor, the IDL you have is legal. Would recommend you to report this to ECP but given the long inactivity of that project probably it will not fixed soon. I do know that one of our Remedy IT engineers has created a more modern IDL editor for Eclipse but due to lack of funding this work is not available publicly.

C#, Gendarme, Sonar and Jenkins : Exclude generated files from Gendarme

I'm working with gendarme for .net called by Sonar (launched by Jenkins).
I've a lot of AvoidVisibleFieldsRule violations. The main violations are found in the generated files. As I can't do anything on it, i would like to exclude *.designer.cs from the scan.
I can't find a way to do that. There is a properties in Sonar to exclude generated files but it doesn't seem to be applied for gendarme.
Is there a way to do such a thing ?
Thanks for all
Gendarme expects you provide an ignore list,
http://www.mono-project.com/Gendarme.FAQ
https://github.com/mono/mono-tools/blob/master/gendarme/self-test.ignore
The ignore file format is bit of weird, but you can learn it by experiments.
Indeed that is actually not normal at all. Generated code is excluded by the plugin with the standard configuration. What version of the C# plugins are you using ?
Anyway, the configuration property you can try is "sonar.exclusions" (see http://docs.codehaus.org/display/SONAR/Advanced+parameters).
If you do not solve your problem right away, the best thing would be to drop a mail to the user mailing list (see http://www.sonarsource.org/support/support/) and send the verbose output of your build. To get this output simply add "-X" to the command line.
Hope it helps