How can I see scala compilation error on the project tree of intellij? - scala

As the screenshot shows, I want to see the compilation error in the project tree on the left.

This feature is usually active automatically. I searched the Scala plugin source on GitHub and couldn't find any uses of the class ProblemFileHighlightFilter which is the class extended to provide the feature you are talking about, so I think it's possible that they simply don't support it.
This feature is quite simple to add though so you can try reporting/requesting it. Their discussion pages are linked in the GitHub repos readme that I linked above.
Before you do though I would suggest quickly going through File > Settings to make sure it isn't just implemented in an unusual way and hiding behind a check box or something.

Related

Path traversal vulnerabilities not found at Scala code

I have been trying to scan my code by using SonarQube + FindBugs + FindSecBugs plugins.
The idea is to detect vulnerabilities in the code, and as it says in the github project subject, it works with scala https://github.com/find-sec-bugs/find-sec-bugs
I have installed the plugin as the documentation says, and tried a few scans but nothing related to vulnerabilities in scala is coming up.
So, in order to figure out if the code was really good or there was a misconfiguration on my SonarQube settings, I went to http://find-sec-bugs.github.io/bugs.htm, I took one of the examples (Potential Path Traversal), inserted the example code and I ran the scanner again. It was not found.
The rule (Security - Potential Path Traversal (file read)) is activated in the Quality Profile, and despite it is a Java profile, it is assigned to the project, since the code in the mentioned example is Scala.
I noticed that all the rules coming from find-sec-bugs are java ones, so I'm wondering if they don't work on scala or there is something else I can do to make it work.
Thanks in advance, and let me know if you need any extra information, I'd be glad to provide you.
Looks like the main reason for that to happen is that Scala bug patterns are explicitly excluded for some reasons:
Their are plenty of limitation with the SonarQube architecture regarding the multi-language support.
It is closely tie to the sonar-source plugin design.
Language can't have the same extension (https://jira.sonarsource.com/browse/MMF-672)
Repository can't contains rule that apply to multiple languages. (If you would have Scala only code, the Java core rules would not be enable unless you have one Java file present)
Sensor are couple to the language definition (depends on the most popular plugin that declares it).
etc, etc..
Source: https://github.com/spotbugs/sonar-findbugs/issues/108#issuecomment-305909652
All the exclusions can be seen here: https://github.com/spotbugs/sonar-findbugs/commit/526ca6b29fae2684f86b1deba074a4be8a05b67e
Particularly, for Scala:
static exclusions = ['CUSTOM_INJECTION',
'SCALA_SENSITIVE_DATA_EXPOSURE',
'SCALA_PLAY_SSRF',
'SCALA_XSS_TWIRL',
'SCALA_XSS_MVC_API',
'SCALA_PATH_TRAVERSAL_IN',
'SCALA_COMMAND_INJECTION',
"SCALA_SQL_INJECTION_SLICK",
"SCALA_SQL_INJECTION_ANORM",
"PREDICTABLE_RANDOM_SCALA"]

Edit an another's plugin

I have a plugin's resource codes and I want to edit. Because I want to change plugin's prefix but it isn't possible unless edit plugin. I tried edit with Eclipse but I had a lot of errors.
If you have source codes of some plugins, there meight be a problem, that they are using some api for example WorldEdit api, but you don't have it added in your project. You have to look into code and find out what they use. Then download the api and add it in Build Path - Right Click the project->Build bath->add external Jars. I hope this will help.
You may be getting errors from imports, API's, etc.
The best way to change this is to contact the developer of the plugin, who has the project themselves. It's not a good idea to change code unless you have full permission; but I will still tell you some possible ways to fix it.
Your imports may be faulty, check those.
Actually REVIEW the code yourself– Don't mess around with things you don't know what they do.
CHANGE YOUR PACKAGE NAMES (This got me before, simple mistake)
If there are comments in the code, use those to your advantage
Google your errors.
If you are new to Java, don't skip to changing code already. TRUST ME. Learn all you can before skipping to other "higher level" developer styles.
Like I said, these are vague and simple ways to fix it; the best way to have your feature implemented is to contact the developer.
*I understand that this thread is old; I'm just saying this because there are currently no answers that describe this for other Google travelers of the internet.

How to force team members to comment using eclipse plugin or something else

Currently, I am working in a new project and it was difficult for me to understand since there is no comment. I wonder if it is possible to force team members(including me) to add more comments. I would like to automate this ject in jenkins later if possible.
You can run static code checks and their corresponding eclipse plug-ins to enforce comments being made in code.
For e.g. in CheckStyle javadoc can be enforced http://checkstyle.sourceforge.net/config_javadoc.html
Also checkstyle can be easily integrated with Jenkins.
You can also use eclipse java compiler settings for javadoc check.
Go to preferences->java->compiler->javadoc to enforce errors and warnings.
Compiler errors and warnings can be easily reported through continuous build
cheers,
Saurav
I can only recommend to be very, very careful with that. Of course, you may use tools like SONAR, Eclipse Settings and the like to enforce comments.
Buuuuuuuut:
You can easily generate comments (/w Eclipse) and -as you probably
know- generated comment is not use/helpful at all.
In case you add a useful comment and it relies too much on the actual implementation, you also have to maintain it. Whenever the code changes you need to validate if the comment does too. This is often overlooked and creates more confusion then by not having any comment at all. Even though you had a good intention in the first place.
"The Truth Lies In The Code"(tm): You can achieve good to understand and easy maintainable code by working very hard on it. This might help to avoid to need any comment at all. Its not easy (and not always possible), I admit that.
At least "public API" must be documented. That could be a rule of thumb and it seems managable in a large code base.
I would rather spend more time in having good understandable code instead of "forced comments". You may achieve the complete opposite by enforcing it.
Using Sonar/Eclipse Settings to enforce documentation of public API makes sense to me though.
This needs to be implemented at the source control level, not the IDE level.
If you're using git, you can look into git hooks http://git-scm.com/docs/githooks
This will let you write little scripts that will be run when you commit code. You can write a script to check if the commit includes a valid comment. You can also perhaps allow skipping of comments with a "-force" option or something like that.

Mark / highlight code in Eclipse (for code review)

In some cases I need to mark (several) lines of code in Eclipse. For example when reviewing, or when testing. Is there a feature or plug-in in Eclipse which can help me to that?
For now I'm just putting #REVIEWED or #TOBEREVIEWED on lines or around blocks. But that is a lot of work.
Any ideas?
EDIT: I'm aware of the Bookmark feature, but that seems to cover only 1 line.
EDIT2: I'm also aware of Task tags like TODO and FIXME, thanks E-Riz
You can use custom task tags in comments (the default is //TODO), which are automatically added to the Markers or Problems views in Eclipse. for example, you could create a custom task tag like //TO-REVIEW.
It's not exactly marking blocks of code, since it's essentially a marker for one line, but it is a convenient way to track and locate them. See the Eclipse Help page for more details.
Why not use some code review features of external server like GitHub?
I mean it could be nice to comment and discuss code blocks just within Eclipse,
but it is much overhead to develop and maintain comparing to web-based solution (that would be universal).
Then possibly such server has similar feature support as Eclipse plugin.
For example
if you use git, you can check GitHub and Eclipse EGit and Eclipse Mylyn tasks.
For perforce there is job concept (similar to issues).
So it leads to understanding that what you actually need is issue-tracker integrated into Eclipse that can conveniently point to code blocks. Again depends on your SCM.
You can us Eclipse plugin like Jupiter for code review. It will help to identify issues (if any) in code blocks with review comments without touching actual code.
The code review comments get stored in jupiter files in your respective project.
Developer can see those issues, fix and comment on them.

Effective comment annotation in Scala Eclipse Plugin?

I was wondering if anyone can explain where and how comment documentation in Scala is applicable - in particular, the Eclipse plugin. For example, is there a way to comment a procedure, that might later show as a help-hint while using Eclipse? I'm not entirely sure how to get these Javadoc like effects when using Scala Eclipse. I've checked the various FAQs for the plugin, it's possibly not supported but I can't find an explanation either way.
You need to use Scaladoc, but it isn't supported completely yet.
ScalaDoc on hover/completion is not yet integrated in the Scala IDE.
The good news is that this feature is currently under development and we plan to have intial support for it in the coming months. A Pull Request for adding ScalaDoc in support in the Scala Presentation Compiler has been recently merged.
A Pull Request on the Scala IDE project will follow. You can track progress on this feature here