Display a second-level warning.

Second-level warnings are warnings that should require investigation, but cannot always be immediately corrected.

  • The correction could be complex. e.g. require a refactorisation or an API change.
  • The correction cannot be done. e.g. Code that use a deprecated API for some compatibility reason.
  • There is not a real issue (false positive). Note that this should be unlikely.
  • Transitional: While a real warning, it fires a lot in current code, so a transition is needed in order to fix them before promoting the advice to a warning.

In order to prevent warning inflation à la Java, second-level warnings are not displayed by default and require an additional option -W.

Return the message (to add information) or null if the warning is disabled

Property definitions

nitc $ ToolContext :: advice
	# Display a second-level warning.
	#
	# Second-level warnings are warnings that should require investigation,
	# but cannot always be immediately corrected.
	#
	# * The correction could be complex. e.g. require a refactorisation or an API change.
	# * The correction cannot be done. e.g. Code that use a deprecated API for some compatibility reason.
	# * There is not a real issue (false positive). Note that this should be unlikely.
	# * Transitional: While a real warning, it fires a lot in current code, so a transition is needed
	#   in order to fix them before promoting the advice to a warning.
	#
	# In order to prevent warning inflation à la Java, second-level warnings are not displayed by
	# default and require an additional option `-W`.
	#
	# Return the message (to add information) or null if the warning is disabled
	fun advice(l: nullable Location, tag: String, text: String): nullable Message
	do
		if is_warning_blacklisted(l, tag) then return null
		var m = new Message(l, tag, text, 0)
		if messages.has(m) then return null
		if l != null then l.add_message m
		if opt_warning.value.has("no-{tag}") then return null
		if not opt_warning.value.has(tag) and opt_warn.value <= 1 then return null
		messages.add m
		warning_count = warning_count + 1
		if opt_stop_on_first_error.value then check_errors
		return m
	end
src/toolcontext.nit:287,2--314,4