From f0ca3e2dc398ceba85e695af9a389ea662f51ed2 Mon Sep 17 00:00:00 2001 From: volodya-lombrozo Date: Thu, 14 Dec 2023 18:11:57 +0300 Subject: [PATCH] feat(#1758): fix all the qulice suggestions --- .../com/rultor/agents/github/CommentsTag.java | 20 ++++++++++------- src/main/java/com/rultor/spi/Profile.java | 6 ++--- .../rultor/agents/github/CommentsTagTest.java | 22 +++++++++---------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/rultor/agents/github/CommentsTag.java b/src/main/java/com/rultor/agents/github/CommentsTag.java index 7341899107..0eab5bb770 100644 --- a/src/main/java/com/rultor/agents/github/CommentsTag.java +++ b/src/main/java/com/rultor/agents/github/CommentsTag.java @@ -93,19 +93,19 @@ public CommentsTag(final Github ghub) { /** * Constructor. - * @param github Github client - * @param profile Profile + * @param ghub Github client + * @param config Profile */ public CommentsTag( - final Github github, - final Profile profile + final Github ghub, + final Profile config ) { super( "/talk/wire[github-repo and github-issue]", "/talk/request[@id and type='release' and success='true']" ); - this.github = github; - this.profile = profile; + this.github = ghub; + this.profile = config; } @Override @@ -154,16 +154,20 @@ public Iterable process(final XML xml) throws IOException { /** * Check if release is prerelease. + * True if profile does not specify release.pre=false. * @return True if prerelease, false otherwise. */ private boolean isPrerelease() { try { + final boolean result; final List xpath = this.profile.read() .xpath("/p/entry[@key='release']/entry[@key='pre']/text()"); if (xpath.isEmpty()) { - return true; + result = true; + } else { + result = "true".equals(xpath.get(0).trim()); } - return "true".equals(xpath.get(0).trim()); + return result; } catch (final IOException exception) { throw new IllegalStateException( String.format( diff --git a/src/main/java/com/rultor/spi/Profile.java b/src/main/java/com/rultor/spi/Profile.java index 504148c2de..ef022389ff 100644 --- a/src/main/java/com/rultor/spi/Profile.java +++ b/src/main/java/com/rultor/spi/Profile.java @@ -199,10 +199,10 @@ public Fixed() { /** * Ctor. - * @param xml Xml lines + * @param lines Xml lines */ - public Fixed(String... xml) { - this(new XMLDocument(String.join("", xml))); + public Fixed(final String... lines) { + this(new XMLDocument(String.join("", lines))); } /** diff --git a/src/test/java/com/rultor/agents/github/CommentsTagTest.java b/src/test/java/com/rultor/agents/github/CommentsTagTest.java index b4615cbe3d..39abd8eb3c 100644 --- a/src/test/java/com/rultor/agents/github/CommentsTagTest.java +++ b/src/test/java/com/rultor/agents/github/CommentsTagTest.java @@ -34,7 +34,6 @@ import com.jcabi.github.Releases; import com.jcabi.github.Repo; import com.jcabi.github.mock.MkGithub; -import com.jcabi.xml.XMLDocument; import com.rultor.spi.Agent; import com.rultor.spi.Profile; import com.rultor.spi.Talk; @@ -169,7 +168,7 @@ public void createsReleaseTitleFromTalk() throws Exception { /** * CommentsTag can create latest release if profile specify 'pre: false'. - * @throws Exception In case of error. + * @throws IOException In case of error. */ @Test public void createsLatestRelease() throws IOException { @@ -182,17 +181,18 @@ public void createsLatestRelease() throws IOException { final Agent agent = new CommentsTag( repo.github(), new Profile.Fixed( - "

false

" + "

", + "", + "", + "false", + "

" ) ); final String tag = "v1.1.latest"; final Talk talk = CommentsTagTest.talk(issue, tag); agent.execute(talk); MatcherAssert.assertThat( - String.format( - "We expect that release with tag '%s' is the latest final release (not a pre-release)", - tag - ), + "We expect latest release to be created (not pre)", new Release.Smart( new Releases.Smart(repo.releases()).find(tag) ).prerelease(), @@ -201,7 +201,8 @@ public void createsLatestRelease() throws IOException { } /** - * CommentsTag can create pre-release by default if profile specify anything. + * CommentsTag can create pre-release by default. + * Check the default behaviour if profile specifies anything. * @throws IOException In case of error. */ @Test @@ -217,10 +218,7 @@ public void createsPreReleaseByDefault() throws IOException { final Talk talk = CommentsTagTest.talk(issue, tag); agent.execute(talk); MatcherAssert.assertThat( - String.format( - "We expect that release with tag '%s' is the pre-release by default if profile does not specify 'pre: false'", - tag - ), + "We expect pre-release to be created by default", new Release.Smart( new Releases.Smart(repo.releases()).find(tag) ).prerelease(),