Skip to content

Commit

Permalink
Extend logging of "legacy" checkers
Browse files Browse the repository at this point in the history
  • Loading branch information
ascheman committed Sep 18, 2024
1 parent a9a7464 commit 7c8cfa0
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.aim42.htmlsanitycheck.check;

import lombok.extern.slf4j.Slf4j;
import org.aim42.htmlsanitycheck.Configuration;
import org.aim42.htmlsanitycheck.collect.SingleCheckResults;
import org.aim42.htmlsanitycheck.html.HtmlPage;
Expand All @@ -11,6 +12,7 @@
import java.util.List;
import java.util.Set;

@Slf4j
public class BrokenCrossReferencesChecker extends SuggestingChecker {
private List<String> listOfIds;
private List<String> hrefList;
Expand All @@ -34,6 +36,7 @@ protected void setValidPossibilities() {

@Override
protected SingleCheckResults check(final HtmlPage pageToCheck) {
log.trace("Checking '{}'", pageToCheck.getFile());
//get list of all a-tags "<a href=..." in html file
hrefList = pageToCheck.getAllHrefStrings();
hrefSet = new HashSet<>(hrefList);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.aim42.htmlsanitycheck.check;

import lombok.extern.slf4j.Slf4j;
import org.aim42.htmlsanitycheck.Configuration;
import org.aim42.htmlsanitycheck.collect.Finding;
import org.aim42.htmlsanitycheck.collect.SingleCheckResults;
Expand All @@ -20,6 +21,7 @@
*
* @see <a href="https://www.w3schools.com/tags/att_a_href.asp">https://www.w3schools.com/tags/att_a_href.asp</a>
*/
@Slf4j
class BrokenHttpLinksChecker extends Checker {

// get the (configured) statusCodes, just syntactic sugar...
Expand Down Expand Up @@ -51,6 +53,7 @@ protected void initCheckingResultsDescription() {

@Override
protected SingleCheckResults check(final HtmlPage pageToCheck) {
log.trace("Checking '{}'", pageToCheck.getFile());

//get set of all a-tags "<a href=..." in html file,
// restricted to http(s) links
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.aim42.htmlsanitycheck.check;

import lombok.extern.slf4j.Slf4j;
import org.aim42.htmlsanitycheck.Configuration;
import org.aim42.htmlsanitycheck.collect.SingleCheckResults;
import org.aim42.htmlsanitycheck.html.HtmlPage;
Expand All @@ -8,6 +9,7 @@
import java.util.List;
import java.util.Set;

@Slf4j
public class DuplicateIdChecker extends Checker {
private Set<String> idStringsSet;
private List<String> idStringsList;
Expand All @@ -25,6 +27,7 @@ protected void initCheckingResultsDescription() {

@Override
protected SingleCheckResults check(final HtmlPage pageToCheck) {
log.trace("Checking '{}'", pageToCheck.getFile());

//get list of all tagsWithId '<... id="XYZ"...' in html file

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.aim42.htmlsanitycheck.check;

import lombok.extern.slf4j.Slf4j;
import org.aim42.htmlsanitycheck.Configuration;
import org.aim42.htmlsanitycheck.collect.Finding;
import org.aim42.htmlsanitycheck.collect.SingleCheckResults;
Expand All @@ -23,6 +24,7 @@
* <p>
* see also: <a href="http://www.w3schools.com/tags/tag_map.asp">http://www.w3schools.com/tags/tag_map.asp</a>
**/
@Slf4j
public class ImageMapChecker extends Checker {
private List<String> mapNames;
private List<HtmlElement> imagesWithUsemapRefs;
Expand All @@ -44,6 +46,7 @@ protected void initCheckingResultsDescription() {

@Override
protected SingleCheckResults check(final HtmlPage pageToCheck) {
log.trace("Checking '{}'", pageToCheck.getFile());

this.pageToCheck = pageToCheck;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.aim42.htmlsanitycheck.check;

import lombok.extern.slf4j.Slf4j;
import org.aim42.htmlsanitycheck.Configuration;
import org.aim42.htmlsanitycheck.collect.SingleCheckResults;
import org.aim42.htmlsanitycheck.html.HtmlElement;
Expand All @@ -8,6 +9,7 @@
/**
* checks for missing or empty alt-attributes in image tags.
*/
@Slf4j
public class MissingAltInImageTagsChecker extends Checker {
public MissingAltInImageTagsChecker(Configuration pConfig) {
super(pConfig);
Expand All @@ -23,6 +25,7 @@ protected void initCheckingResultsDescription() {

@Override
protected SingleCheckResults check(final HtmlPage pageToCheck) {
log.trace("Checking '{}'", pageToCheck.getFile());
// the number of checks is calculated by counting
// ALL image tags:
getCheckingResults().setNrOfChecks(pageToCheck.getAllImageTags().size());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.aim42.htmlsanitycheck.check;

import lombok.extern.slf4j.Slf4j;
import org.aim42.htmlsanitycheck.Configuration;
import org.aim42.htmlsanitycheck.collect.SingleCheckResults;
import org.aim42.htmlsanitycheck.html.HtmlElement;
Expand All @@ -14,6 +15,7 @@
import java.util.List;
import java.util.regex.Pattern;

@Slf4j
public class MissingImageFilesChecker extends Checker {

private static final Logger logger = LoggerFactory.getLogger(MissingImageFilesChecker.class);
Expand All @@ -35,6 +37,7 @@ protected void initCheckingResultsDescription() {

@Override
protected SingleCheckResults check(final HtmlPage pageToCheck) {
log.trace("Checking '{}'", pageToCheck.getFile());
final File file1 = pageToCheck.getFile();
final File file = (file1 == null ? null : file1.getParentFile());
currentDir = file != null ? file : baseDir;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.aim42.htmlsanitycheck.check;

import lombok.extern.slf4j.Slf4j;
import org.aim42.htmlsanitycheck.Configuration;
import org.aim42.htmlsanitycheck.collect.SingleCheckResults;
import org.aim42.htmlsanitycheck.html.HtmlPage;
Expand All @@ -15,6 +16,7 @@
import java.util.Set;
import java.util.stream.Collectors;

@Slf4j
public class MissingLocalResourcesChecker extends Checker {
public static final String MLRC_MESSAGE_PREFIX = "local resource";
public static final String MLRC_MESSAGE_MISSING = "missing";
Expand Down Expand Up @@ -47,6 +49,7 @@ protected void initCheckingResultsDescription() {

@Override
protected SingleCheckResults check(final HtmlPage pageToCheck) {
log.trace("Checking '{}'", pageToCheck.getFile());
//get list of all anchor-tags containing href="xyz" in html file
List<String> allHrefs = pageToCheck.getAllHrefStrings();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.aim42.htmlsanitycheck.tools;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.validator.routines.InetAddressValidator;

import java.net.InetAddress;
Expand All @@ -12,6 +13,7 @@
import java.util.Set;
import java.util.regex.Pattern;

@Slf4j
public class Web {

private Web() {
Expand Down Expand Up @@ -219,6 +221,7 @@ public static boolean isLocalResource(String link) {
} else {
URI aUri;
try {
log.trace("Trying to resolve URI for '{}'", link);
aUri = new URI(link);
} catch (URISyntaxException e) {
throw new InvalidUriSyntaxException(e);
Expand Down

0 comments on commit 7c8cfa0

Please sign in to comment.