Why does codacy give `Unnecessary block` error for function declaration? - static-analysis

We are using codacy for static code analysis. On pushing a change to the js file, where we are declaring a function that returns an object, it is giving the below error.
Internally, codacy tells us this is reported since PMD 5.0. We are not sure if this is an actual issue in the code or in the analyzer. If it is a code issue then what is the correct way to solve this?
EDIT:
Using PMD version 6.48.0

This issue is Open with PMD here.
https://github.com/pmd/pmd/issues/4129
There are workarounds mentioned. For the codacy side we need to disable the rule until it is fixed

Related

After updating to cypress 12.0.0, my test is throwing an error in the cypress-if package

After updating to cypress 12.0.0, I get the following error, how can I fix it?
Cypress has split commands that return elements into a "queries" category and internally implemented them differently.
This was partly to handle "detached from DOM" errors better and more automatically.
The official word is the Cypress.Commands.overwrite() function was left out of the new query API due to the complexity, but they will consider adding it (back?) in if there are enough use-cases presented.
Therefore, you should contribute your use-case to the issue here if you wish to continue using cypress-if and also keep up-to-date with Cypress versions.
Note, you can still add new commands to Cypress, and you can still overwrite some commands just not cy.get(), cy.find(), and cy.contains().
Overwriting commands in v12.0.0 can't be done right now. Here is the github issue.
https://github.com/cypress-io/cypress/issues/25078

Property 'isiOSOnMac' not found on object of type 'NSProcessInfo'

I am having this issue on specific system only(Mac mini). how can I resolve this?
You just need to comment that block of code where you are having this error.
after that you are able to make a build successfully.

Call to undefined method DateTime::getTimezone()

For some reason most of my pages are giving this error "Call to undefined method DateTime::getTimezone()". I'm kind of positive that the pages that have this error got a ->created_at->diffForHumans() function. I still have no idea whats causing this.. It has been working fine since forever.
I tried updating my packages but there was no luck there.. Searched around for the function itself or inside my controllers.. also no luck. Checked my time zone in config/app.php and it had the same time zone that I've always had which is Asia/Amman
Check this discussion please:
https://github.com/laravel/framework/issues/24886
As it say there:
This issue is closed as it is not an issue with Laravel; it was an
issue with the PHP docs at the time, which have since been updated. I
would suggest you review your own code and make sure it's not a
namespace problem (i.e. use new \DateTime instead of new DateTime) and
if you still can't figure it out, post a question on StackOverflow
with the minimum amount of code needed to reproduce the error.
Edit:
Since this was after a Composer update, I would guess that the problem
lies with one of the packages that were updated. The error message
should give you the exact line number producing the error, which
should help you determine what package is causing the error. Then file
a bug report (or pull request) against that package if possible.
I hope it helps.
I kept changing the php version and it eventually worked. It was 7.1.22 and I changed it to 7.2.* and it worked just fine...

error-adding-node-to-odl-via-restconf/

I'm trying to add a netconf-connector into my Open Daylight Nitrogen controller and keep coming up against this error:
">Error parsing input: Could not find module for namespace urn:opendaylight:params:xml:ns:yang:controller:md:sal:connector:netconf"
I'm posting to rest via the postman application using the below URL and Schema used in the guide below:
"http://192.168.0.1:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/controller-config/yang-ext:mount/config:modules"
Has anyone had the same issue, this is the guide I'm following..
http://docs.opendaylight.org/en/stable-nitrogen/user-guide/netconf-user-guide.html
I found the same issue reported on the old Open Daylight forum but it went un-answered..
https://ask.opendaylight.org/question/28561/error-adding-node-to-odl-via-restconf/
Thanks,
Simon
Judging from the error message, you tried to use the controller-config loopback mechanism. This mechanism was deprecated and I believe was completely removed in Nitrogen (unfortunately the documentation wasn't updated to indicate this). Either way, you should use the mechanism outlined in the "Netconf-connector configuration with MD-SAL" section.

How to get the code causing an issue in SonarQube or a link to it?

Is there a way to parameter the SonarQube web service to get the line of the code causing a specific error?
For instance, if I parameter the webservice to get all the blocking issues like this:
http://localhost:9000/api/issues/search?severities=BLOCKER
the Json returned gives the line's number of the issues but not the line's code. How to have the code of those lines?
Otherwise, is there a possibility to get a link to the line causing the error?
Thank you in advance
Check out the WebAPI documentation embedded in your SonarQube server (linked at the footer). For your specific use-case you'll see that this is a good match: api/sources .

Resources