All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.deque.axe.android.AxeDevToolsConf.kt Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
package com.deque.axe.android

import com.deque.axe.android.constants.AxeImpact

object AxeDevToolsConf {
    /**
     * Filter objects and iterate over them.
     * @param filterable The filter.
     * @param axeConf The AxeConf object.
     * @param  The type.
     * @return An instance that was filtered.
     */
    fun  filter(filterable: Filterable, axeConf: AxeConf?): T {
        val ignoredRules: MutableSet = HashSet()
        axeConf?.rules?.toList()?.forEach { value ->
            if (value.second.ignored) {
                ignoredRules.add(value.first)
            }
        }
        return filterable.ignoredResults(
            ignoredRules,
            axeConf != null && axeConf.issueFilterConf.onlyShowResultsVisibleToUser
        )
    }

    /**
     * Get the impact for a given rule.
     * @param axeConf The AxeConf.
     * @param ruleId The ruleId
     * @return The impact.
     */
    fun getImpactForRule(axeConf: AxeConf, ruleId: String?): Int {
        return if (axeConf.rules.containsKey(ruleId)) {
            axeConf.rules[ruleId]!!.impact
        } else {
            AxeImpact.SERIOUS.value
        }
    }

    interface Filterable {
        fun ignoredResults(ruleIds: Set, filterOutNonIntractableResults: Boolean): T
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy