sksamuel / hoplite

A boilerplate-free Kotlin config library for loading configuration files as data classes
Apache License 2.0
924 stars 74 forks source link

Code for unresolved substitution checking appears to be unused #396

Open cloudshiftchris opened 1 year ago

cloudshiftchris commented 1 year ago

This code in ConfigParser (see HERE comment inline) does not use the results of configuring for unresolved substitution checking.

  fun <A : Any> decode(
    kclass: KClass<A>,
    environment: Environment?,
    resourceOrFiles: List<String>,
    propertySources: List<PropertySource>,
    configSources: List<ConfigSource>,
  ): ConfigResult<A> {

    if (decoderRegistry.size == 0)
      return ConfigFailure.EmptyDecoderRegistry.invalid()

    return loader.loadNodes(propertySources, configSources, resourceOrFiles).flatMap { nodes ->
      cascader.cascade(nodes).flatMap { node ->
        val context = context(node)
        preprocessing.preprocess(node, context).flatMap { preprocessed ->
          check(preprocessed).flatMap {

            // HERE ^^^: results of check() (implicit `it` variable in above flatMap) are not used below
            val decoded = decoding.decode(kclass, preprocessed, decodeMode, context)
            val state = createDecodingState(preprocessed, context, secretsPolicy)

            // always do report regardless of decoder result
            if (useReport) {
              Reporter(reportPrintFn, obfuscator, environment)
                .printReport(propertySources, state, context.reporter.getReport())
            }

            decoded
          }
        }
      }
    }
  }