Closed danglotb closed 2 years ago
I'd like to try this. Please assign this issue to me.
If you'll assign me, I have two questions. The first question. I have read the CONTRIBUTING.md, should I create a pull request for each of these 4 modifications? The second question is ・Do something with the "boolean" value returned by "delete". To solve this, what should we do if outputFd.delete() returns false? I think if delete() fails, then mkdir() will also fail.
I'm not used to contributing. And I'm not very good at English, so I'm sorry if the text doesn't make sense to you.
Hello @dendritett
Welcome to Diff-JJoules! We are glad to have you here. :tada:
I would prefer you do one pull request per task, so 4 different pull requests in order to separate the concerns :smile:
I think that the idea of the first task is to check if the .delete()
succeed or not, if not, I agree that we will throw an Exception
in order to stop Diff-JJoules.
I suggest using a RuntimeException
in order to avoid having to declare the exception in the constructor/method.
IHMO, the message should be simple, something like:
Something went wrong when trying to delete the folder <path to the folder>, please check your configuration
Thank you very much! Do not hesitate to ask for more details if you have any doubt. We can also discuss on the pull-request when you open it.
Thank you for your kindness. 😄 I'm going to try this.
I have one question. I'm planning to handle the remaining bugs reported as well, what should I do if there is no value of Optional?
Currently I think it throws a NoSuchElementException, should I have it throw a RuntimeException as well? Or should I not let it throw an exception and let it continue processing? For example
final CtAnnotation<? extends Annotation> testAnnotation =
ctMethod.getAnnotations()
.stream()
.filter(ctAnnotation -> ctAnnotation.getType().getQualifiedName().endsWith("Test"))
.findAny()
.orElse();
if(testAnnotation != null){
testAnnotation.replace(factory.createAnnotation(reference));
}
super.instrumentedTypes.add(declaringType);
Hello,
The fact is that I think that the then branch of this if
will be dead code because we have the following implementation of the method isToBeProcessed()
:
@Override
public boolean isToBeProcessed(CtMethod<?> candidate) {
return super.isToBeProcessed(candidate) && candidate.getAnnotations()
.stream()
.anyMatch(ctAnnotation -> ctAnnotation.getType().getQualifiedName().endsWith("Test"));
}
Therefore, if noneMatch()
, i.e. the opposite of findAny()
, then the method process()
won't be called. Thats the limit of the static analysis of Sonar.
However, we might be good student and apply your solution or use the method ifPresent()
from the Stream
API of Java:
ctMethod.getAnnotations()
.stream()
.filter(ctAnnotation -> ctAnnotation.getType().getQualifiedName().endsWith("Test"))
.findAny()
.ifPresent(ctAnnotation -> ctAnnotation.replace(factory.createAnnotation(reference)));
As you want.
Thank you for explaining so politely and thoroughly.
The method of using ifPresent()
seems to maintain coverage without the need for additional test code.
I'll try it that way.
You completed the four tasks, great job!
Thank you kindly for all your help!
I'm glad my first contribution was to you.
I had only ever written sources in Japan. So I am happy to be able to interact with people from all over the world in this way.:smile:
Sonar gives us a list of "Bugs"