MER-C / wiki-java

A MediaWiki bot framework in Java
GNU Affero General Public License v3.0
66 stars 58 forks source link

Make getPageInfo tell whether a page is a redirection or not #178

Closed PeterBowman closed 4 years ago

PeterBowman commented 4 years ago

If I'm correct, you can only tell whether a page is a redirection or not by using the Wiki.resolveRedirects method, which returns a list of pages the arguments redirect to or, if not a redirection, the pages themselves. This is a bit cumbersome since the way to deal with it is to check for equality between titles:

var titles = List.of(...);
var maybeRedirs = wiki.resolveRedirects(titles);

for (int i = 0; i < titles.size(); i++) {
    if (!maybeRedirs.get(i).equals(titles.get(i))) {
        // this is a redirection
    }
}

I think the getPageInfo method is a better fit.

codecov-commenter commented 4 years ago

Codecov Report

Merging #178 into master will increase coverage by 0.01%. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #178      +/-   ##
============================================
+ Coverage     37.97%   37.98%   +0.01%     
  Complexity      672      672              
============================================
  Files            33       33              
  Lines          5991     5992       +1     
  Branches       1038     1038              
============================================
+ Hits           2275     2276       +1     
  Misses         3549     3549              
  Partials        167      167              
Impacted Files Coverage Δ Complexity Δ
src/org/wikipedia/Wiki.java 51.01% <100.00%> (+0.01%) 354.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6847408...0993b97. Read the comment docs.

MER-C commented 4 years ago

This was merged in cfa27b11.