Wiki
Version 3 (modified by gauthier, 15 years ago)

reply to chuck message

Please look at theses error messages, find duplicates, find a english readable enumeration member name and put it in the enum at the bottom of the code.

If few of you do this, there will be the base for cobra warning refactoring, thanks.

""" purpose: refactor this ("grep -rn .warning( *.cobra " from r1903): 
BinaryOpExpr.cobra:277:					.compiler.warning(this, 'Setting a parameter ("[leftName]") to a class variable ("[rightName]") is often a mistake. You may want to reverse the assignment.')
"""
#BinaryOpExpr.cobra:534:						.compiler.warning(this, 'Both the left and right sides of "[opName]" are value types ("[leftType.name]" and "[rightType.name]"), but "[opName]" applies to reference types. Use "[altName]" instead.')
"""
BinaryOpExpr.cobra:537:						.compiler.warning(this, 'The left side of "[opName]" is a value type ("[leftType.name]") while the right side is an incompatible reference type ("[rightType.name]").')
BinaryOpExpr.cobra:539:						.compiler.warning(this, 'The right side of "[opName]" is a value type ("[rightType.name]") while the left side is an incompatible reference type ("[leftType.name]").')						
BinaryOpExpr.cobra:614:				.compiler.warning(this, 'An explicit "this" literal is unnecessary for accessing members of the current object. You can remove "this".')
BinaryOpExpr.cobra:616:				.compiler.warning(this, 'An explicit dot (".") is unnecessary for accessing underscored members of the current object. You can remove ".".')
BinaryOpExpr.cobra:673:				.compiler.warning(this, 'The result of "[member.name]" should be used in an expression such as assignment or passing arguments (as indicated by its MustUseResult attribute).')
BinaryOpExpr.cobra:744:						.compiler.warning(this, 'The expression is always of type "[.right.toCobraSource]".')
BinaryOpExpr.cobra:753:						.compiler.warning(this, 'The expression will always be of type "[.right.toCobraSource]" when not nil. You can just check for not nil by removing "inherits [.right.toCobraSource]".')
BinaryOpExpr.cobra:761:									.compiler.warning(this, 'The expression is always of type "[.right.toCobraSource]".')
BinaryOpExpr.cobra:765:								.compiler.warning(this, 'The expression (of type "[leftType.name]") is never of type "[.right.toCobraSource]".')
BinaryOpExpr.cobra:772:						.compiler.warning(this, 'The expression (of type "[leftType.name]") is never of type "[.right.toCobraSource]".')
BinaryOpExpr.cobra:834:					.compiler.warning(this, 'The given expression is already a "[_rightTypeExpr.toCobraSource]", but nilable. You can just use "to !".')
BinaryOpExpr.cobra:837:					.compiler.warning(this, 'The given expression is already a "[_left.type.name]", but not nilable. You can just use "to ?".')
BinaryOpExpr.cobra:839:				.compiler.warning(this, 'The given expression is already a "[_rightTypeExpr.toCobraSource]" so the typecast is redundant. You can remove it.')
Boxes.cobra:1092:			.compiler.warning(this, 'When attributes are declared, they should be suffixed with "Attribute".')
CobraParser.cobra:37:	def warning(we as CobraWarning)
"""
#CobraParser.cobra:197:				_warning('File is empty.')
#CobraParser.cobra:199:				_warning('File is completely blank.')
#CobraParser.cobra:450:			_warning('Colons are not used to start indented blocks. You can remove the colon.')
#CobraParser.cobra:488:			_warning('Colons are not used to start indented blocks. You can remove the colon.')
"""
CobraParser.cobra:592:				_warning(msg)
CobraParser.cobra:793:					_warning(.last, '"fake" has been deprecated. Use "extern" instead.')  # deprecated on 2008-10-03
CobraParser.cobra:1214:			_warning('Encountered "pass" in a class that already has declared members.')  # TODO: change to an error
"""
#CobraParser.cobra:1264:				_warning('Colons are not used to start indented blocks. You can remove the colon.')
"""
CobraParser.cobra:1266:				_warning('Colons are not required with invariants. You can remove the colon.')
CobraParser.cobra:1315:			_warning(opener, 'Unnecessary parentheses. You can remove them.')
CobraParser.cobra:1428:				_warning(opener, 'Unnecessary parentheses. You can remove them.')
CobraParser.cobra:1529:					_warning(.peek, 'Interface `test` sections are parsed, but ignored. In the future, classes will acquire the tests of the interfaces they implement.')
CobraParser.cobra:1665:					_warning(.peek, 'Interface `test` sections are parsed, but ignored. In the future, classes will acquire the tests of the interfaces they implement.')
CobraParser.cobra:1716:				_warning('The first parameter is "self" which may be a Python carry-over on your part. Cobra does not require that (and calls it "this" anyway).')
CobraParser.cobra:1859:					_warning('More than 100 lines of code ([codePart.statements.count] toplevel statements) in method [fullName].') 
CobraParser.cobra:2415:				_warning('Colons are not used to put a target statement on the same line. Use a comma (,) instead.')
CobraParser.cobra:2588:					_warning(expr.token, 'Unnecessary parentheses around expression. You can remove them.')
CobraParser.cobra:3088:				_warning('Assuming empty dictionary, but please use "{:}" for empty dictionary or "{,}" for empty set')
CobraParser.cobra:3490:	def _warning(msg as String)
CobraParser.cobra:3491:		_warning(.last, msg)
CobraParser.cobra:3493:	def _warning(token as IToken, msg as String)
CobraParser.cobra:3494:		_warningRecorder.warning(CobraWarning(_fileName, token, msg))
"""
#Compiler.cobra:1187:				.warning(CobraWarning(fileName, nil, 'Cannot write source code corrections due to: [exc.message] ([exc.getType.name]).'))
"""
Compiler.cobra:1348:	def warning(node as ISyntaxNode, msg as String)
Compiler.cobra:1350:		.warning(CobraWarning(node.token, msg))
Compiler.cobra:1352:	def warning(cw as CobraWarning)
Expr.cobra:552:				.compiler.warning(this, 'Unnecessary parentheses. You can remove them.')
Expr.cobra:2034:			.compiler.warning(this, 'The value nil will always evaluate to false.')
Expr.cobra:2065:				.compiler.warning(_notExpr, 'The expression "[_notExpr.toCobraSource]" (of type "[type.name]") will never evaluate to false because the expression is not nilable. [hint]')
Expr.cobra:2075:				.compiler.warning(this, 'The expression "[_expr.toCobraSource]" (of type "[type.name]") will always evaluate to true because it is not nilable. [hint]')
Expr.cobra:2957:			.compiler.warning(this, 'The given expression is already nilable so "to ?" is redundant. You can remove it.')  # TODO: needs test case
Expr.cobra:2988:			.compiler.warning(this, 'The given expression is already non-nilable so "to !" is redundant. You can remove it.') # TODO: needs test case
InstallFromWorkspace.cobra:156:	def warning(msg)
"""
#Members.cobra:215:				.compiler.warning(this, 'Duplicate modifier "[name]". You can remove it.')
"""
Members.cobra:354:				.compiler.warning(this, 'Cannot locate a single invoke method of "[_handlerType.name]".')
Members.cobra:358:				.compiler.warning(this, 'Cannot determine parameters of event "[.name]".')
Members.cobra:831:				.compiler.warning(local, 'The value of variable "[local.name]" is never used.')
Members.cobra:1080:		if .name == '__init__', .compiler.warning(this, 'Initializers are named "init" with no surrounding underscores.')
NameSpace.cobra:192:			.compiler.warning(this, 'Namespace names should start with an uppercase letter in order to avoid collisions with other identifiers such as arguments and local variables.')
NameSpace.cobra:210:						.compiler.warning(this, 'Multiple namespaces in "[.fullName]" differ only by case: ' + namesMsgPart)
NameSpace.cobra:217:						else, .compiler.warning(this, msg)
Node.cobra:1174:	def warning(node as ISyntaxNode, msg as String)  # TODO: move to IWarningRecorder
Statements.cobra:973:					.compiler.warning(this, unThis)
Statements.cobra:977:					.compiler.warning(this, unThis)
TypeProxies.cobra:220:				# TODO: .compiler.warning(msg)
TypeProxies.cobra:273:				# TODO: .compiler.warning(msg)
"""

enum WarningMessage
	FoundDuplicateModifier                       # 'Duplicate modifier "[name]". You can remove it.'
	FoundEmptyFile                               # 'File is empty.' / 'File is completely blank.'
	FoundBeginBlockLineEndedWithColon            # 'Colons are not used to start indented blocks. You can remove the colon.'
	ExceptionWhileSourceCorrection               # 'Cannot write source code corrections due to: [exc.message] ([exc.getType.name]).'
	# 'Setting a parameter ("[leftName]") to a class variable ("[rightName]") is often a mistake. You may want to reverse the assignment.'
	IncorrectOperatorUseWithValueTypes           # 'Both the left and right sides of "[opName]" are value types ("[leftType.name]" and "[rightType.name]"), but "[opName]" applies to reference types. Use "[altName]" instead.'
	

Discussion

2009-01-14, Chuck Esterbrook: Why is this a wiki page instead of a ticket? How does this help document Cobra for the users?

2009-01-15, Gauthier Segay: I just took a post from you about  Warning Id for the compiler and checked the use of warning signaling, instead of skipping to another task I thought the wiki could be a workspace for editing the messages and have your agreement for the enumeration name before someone could commit to the patch.