Skip to content
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

pom.xml:348-352: Enable RuleAssertionMessage. This rule... #2297

Closed
0pdd opened this issue Jul 21, 2023 · 10 comments · Fixed by #3113
Closed

pom.xml:348-352: Enable RuleAssertionMessage. This rule... #2297

0pdd opened this issue Jul 21, 2023 · 10 comments · Fixed by #3113
Assignees
Milestone

Comments

@0pdd
Copy link

0pdd commented Jul 21, 2023

The puzzle 2171-74d15acf from #2171 has to be resolved:

eo/pom.xml

Lines 348 to 352 in 992706f

@todo #2171:30min Enable RuleAssertionMessage.
This rule is disabled because lots of tests in the
project are written without assertion messages. We have
to add all messages for all assertions and then enable
that rule and remove that puzzle.

The puzzle was created by rultor on 21-Jul-23.

Estimate: 30 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

@yegor256
Copy link
Member

yegor256 commented Aug 8, 2023

@volodya-lombrozo
Copy link
Member

@yegor256 I'm not sure about "removing". Maybe it's better just to disable that check by default. What do you think?
As for PMD check - Why does not this check work in eo project? Does qulice uses the old version of PMD?

@Graur Graur added this to the Routine milestone Aug 14, 2023
@c71n93
Copy link
Member

c71n93 commented Apr 15, 2024

@volodya-lombrozo @yegor256 for now qulice has check for assertions without messages and now all assertions contain messages (most of them are stubs). So I tried to enable the JTCOP.RuleAssertionMessage and faced with some problems. For example:

Method 'checksTypoPacks' has assertion without message: 'MatcherAssert.assertThat(EoSyntaxTest.EMPTY_MSG, XhtmlMatchers.xhtml(xml.toString()), XhtmlMatchers.hasXPaths("/program/errors/error/@line"))'. 
Please add the explanation message to make the test more readable.

Here, assertion contains a stub message (EoSyntaxTest.EMPTY_MSG), however JTCOP.RuleAssertionMessage still fails for some reason.

I think this todo should be removed, because main problem was solved, but first we need to resolve such contradiction. What do you think about disabling this jtcop rule by default?

@volodya-lombrozo
Copy link
Member

volodya-lombrozo commented Apr 15, 2024

@c71n93 Can you just create an issue in the jtcop repository, please? I will fix it.

@c71n93
Copy link
Member

c71n93 commented Apr 16, 2024

@volodya-lombrozo It seems like theres another bug. For example:

[ERROR] The test class OptimizeMojoTest.java (/Users/c71n93/Programming/EOLANG/eo/eo-maven-plugin/src/test/java/org/eolang/maven/OptimizeMojoTest.java:) has encountered some problems. Please review the results for more information.
[ERROR]         2) Method choosesTransformerFactoryInConcurrentEnvironment doesn't have assertion statements.
[ERROR]         Please add at least one assertion statement to the test method.
[ERROR]         You can also ignore the rule by adding @SuppressWarnings("JTCOP.RuleAssertionMessage") annotation.
[ERROR]         Rule: RuleAssertionMessage.

The test looks like this:

    @Test
    void choosesTransformerFactoryInConcurrentEnvironment() {
        for (final Class<? extends TransformerFactory> clazz : IntStream.range(0, 100).parallel()
            .mapToObj(i -> TransformerFactory.newInstance().getClass())
            .collect(Collectors.toList())) {
            MatcherAssert.assertThat(
                "TO ADD ASSERTION MESSAGE",
                clazz,
                Matchers.typeCompatibleWith(TransformerFactoryImpl.class)
            );
        }
    }

Will you fix it? It looks like check ignores asserts inside of loops.

@c71n93
Copy link
Member

c71n93 commented Apr 16, 2024

@volodya-lombrozo @yegor256 also there was cases, that was not detected by qulice, but detected by jtcop. For example:

    @Test
    void failsOnTimeout(@TempDir final Path temp) {
        Assertions.assertThrows(
            IllegalStateException.class,
            () -> new FakeMaven(temp)
                .withHelloWorld()
                .with("timeout", 0)
                .execute(InfiniteMojo.class),
        );
    }

For some reasons qulice ignores Assertions.assertThrows. I start resolving such errors.
@volodya-lombrozo do you mind to reassign this issue on me?

@volodya-lombrozo
Copy link
Member

@c71n93

Will you fix it? It looks like check ignores asserts inside of loops.

For sure. Again, could report a bug in jtcop, please?

@volodya-lombrozo do you mind to reassign this issue on me?

Yes, of course.

@c71n93
Copy link
Member

c71n93 commented Apr 17, 2024

@volodya-lombrozo could you check this one too, please volodya-lombrozo/jtcop#357. It also related to this ticket.

@volodya-lombrozo
Copy link
Member

@c71n93 Yes, I'll take a look.

c71n93 added a commit to c71n93/eo that referenced this issue Apr 19, 2024
@c71n93 c71n93 mentioned this issue Apr 19, 2024
c71n93 added a commit to c71n93/eo that referenced this issue Apr 19, 2024
c71n93 added a commit to c71n93/eo that referenced this issue Apr 19, 2024
c71n93 added a commit to c71n93/eo that referenced this issue Apr 19, 2024
c71n93 added a commit to c71n93/eo that referenced this issue Apr 19, 2024
@0pdd
Copy link
Author

0pdd commented Apr 23, 2024

@0pdd 3 puzzles #3130, #3131, #3132 are still not solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants