-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Existing Sorald code is not generating remediated code #589
Comments
Hello, I will try to answer your questions.
I am trying on Linux and it works for me. I ran the command below. java -jar target/sorald-0.3.1-SNAPSHOT-jar-with-dependencies.jar repair --source UnusedPrivateField.java --rule-key 1068
The source file you pass using
On the first try, your soruce file would have been repaired and now there are no violations so sorald does nothing like your console says. Verify your |
Hi @PrakashNayak,
That repair works fine on my end, so likely there is something ##with your environment that is causing Sorald to not do its job. Based on the file path, it looks like you are running Windows? Sorald currently isn't tested on Windows (see #273), and so there may be some Windows-specific problem. I don't have a Windows machine at hand right now, but I can try running this on Windows tonight after work hours to see if that's where the problem stems from.
By default, the repair is enacted in-place. That is to say, the input file is overwritten.
The one thing that strikes me as a little bit odd is that the filepath starts with Could you provide the output of |
Also what @algomaster99 said about the in-place repair: you might already have repaired the violation. |
@slarse I just tried on Windows and it doesn't work. I get the same output as @PrakashNayak
I tried debugging it and found out that it is able to detect the position of violation but sorald is not able to repair it. The |
Good, then we know it's a Windows thing.
On a limb, that's likely something with an assumption of how filepaths work that doesn't hold on Windows. This kind of falls into #273 though, we just need to officially add support for Windows. |
My Maven Version is --> Apache Maven 3.6.3 |
Hi @PrakashNayak , Could you give the full output of In any case, we've narrowed this down to a bug in using Sorald with Windows. Unfortunately, we do not currently support Windows, but it is in the pipeline (see #273). |
@PrakashNayak If you're in a hurry you can try the version on the branch in #591, it should work for you. We'll have it merged into master sometime next week. |
Steps I followed
git clone https://github.com/SpoonLabs/sorald.git
cd sorald
mvn package -DskipTests
4 cp target/sorald-*-jar-with-dependencies.jar sorald.jar
Opend the command prompt
Ran below command
repair --source C:/test/solard_code/sonarqube-repair/source/act/UnusedPrivateField .java --rule-key 1068
This is Original file
public class UnusedPrivateField {
private String a = "Hello world!";
public int compute(int number) {
return number * 42;
}
}
Output in console
INFO JavaClasspath initialization
INFO JavaClasspath initialization (done) | time=81ms
INFO JavaTestClasspath initialization
INFO JavaTestClasspath initialization (done) | time=0ms
INFO Java Main Files AST scan
INFO 1 source files to be analyzed
INFO 1/1 source files have been analyzed
INFO Java Main Files AST scan (done) | time=1273ms
INFO Java Test Files AST scan
INFO 0 source files to be analyzed
INFO Java Test Files AST scan (done) | time=1ms
INFO 0/0 source files have been analyzed
INFO Java Generated Files AST scan
INFO 0 source files to be analyzed
INFO Java Generated Files AST scan (done) | time=1ms
INFO 0/0 source files have been analyzed
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
-----Number of fixes------
UnusedPrivateFieldProcessor: 0
-----End of report------
I want answer of below questions
1 . Why its not removing the unused private variable?
2. Where file will get generated ?
3. Am I doing any mistake in running the command
Testing.zip
I want to two things here first it should remove the unused variable and remove the unusedprivate fields.
Please help me and let me know @prakash.bit.nayak@gmail.com
The text was updated successfully, but these errors were encountered: