class locations_node¶
Used by warningclass report() and report_return_warnings() methods that report a warning with a list of code locations.
locations_node Members¶
| Constructor | __init__() |
| Methods | __repr__(), __str__(), get_end_col(), get_end_line(), get_event(), get_file(), get_flags(), get_start_col(), get_start_line() |
locations_node Details¶
-
class
cs.locations_node¶ Used by
warningclassreport()andreport_return_warnings()methods that report a warning with a list of code locations.-
__init__(_sfi, _line, _event, _flags)¶ Constructor.
Parameters: - _sfi (
sfileinst) – The file instance (sfileinst) in which the event occurs. - _line (int) – The line (line_number) in
_sfiat which the event occurs. - _event (str) – A short description of the problem. If empty, no event will be associated with this node.
- _flags (
locations_node_flags) –locations_node_flagsthat characterize the node.
Raises: OverflowError>>> sf = next(s for s in project.current().sfiles() if s.name().endswith('apitest.cpp')) >>> sfi = sf.arbitrary_instance() >>> locations_node(sfi, 90, 'security issue', locations_node_flags.STYLE1) <cs.locations_node <cs.sfileinst C:\alex\test\apitest.cpp>: 90:0..90:0, security issue, cs.locations_node_flags style1>
- _sfi (
-
__init__(_sfi, _start_line, _end_line, _start_col, _end_col, _event, _flags)¶ Constructor.
Parameters: - _sfi (
sfileinst) – The file instance (sfileinst) in which the event occurs. - _start_line (int) – The line (line_number) in
_sfiat which the event starts. One-based. - _end_line (int) – The line (line_number) in
_sfiat which the event ends. One-based. Inclusive. - _start_col (int) – The column (column_number) on
_start_linewhere the event starts. Zero-based. - _end_col (int) – The column (column_number) on
_end_linewhere the event ends. Zero-based. Exclusive. The value 0 is special and means end of line. - _event (str) – A short description of the problem. If empty, no event will be associated with this node.
- _flags (
locations_node_flags) –locations_node_flagsthat characterize the node.
Raises: result.ERROR_INVALID_ARGUMENTif relationships between specified_start_line,_end_line,aresuch that they cannot describe a valid span (in any file).>>> sf = next(s for s in project.current().sfiles() if s.name().endswith('apitest.cpp')) >>> sfi = sf.arbitrary_instance() >>> locations_node(sfi, 2, 3, 20, 4, 'security issue', locations_node_flags.STYLE2) <cs.locations_node <cs.sfileinst C:\alex\test\apitest.cpp>: 2:20..3:4, security issue, cs.locations_node_flags style2>
- _sfi (
-
__repr__()¶ Get a representation of a
locations_nodeobject that includes information useful for debugging.Return type: str Returns: The string representation. >>> sf = next(s for s in project.current().sfiles() if s.name().endswith('apitest.cpp')) >>> sfi = sf.arbitrary_instance() >>> n = locations_node(sfi, 90, 'security issue', locations_node_flags.STYLE1) >>> repr(n) '<cs.locations_node <cs.sfileinst C:\\alex\\test\\pyapi\\apitest.cpp>: 90:0..90:0, security issue, cs.locations_node_flags style1>'
-
__str__()¶ Get a simple string representation of a
locations_nodeobject.Return type: str Returns: The string representation. >>> sf = next(s for s in project.current().sfiles() if s.name().endswith('apitest.cpp')) >>> sfi = sf.arbitrary_instance() >>> n = locations_node(sfi, 90, 'security issue', locations_node_flags.STYLE1) >>> str(n) '<cs.locations_node <cs.sfileinst C:\\alex\\test\\pyapi\\apitest.cpp>: 90:0..90:0, security issue, cs.locations_node_flags style1>'
-
get_end_col()¶ Get the end column from a
locations_node.Return type: int Returns: The node’s ending column. >>> sf = next(s for s in project.current().sfiles() if s.name().endswith('apitest.cpp')) >>> sfi = sf.arbitrary_instance() >>> n = locations_node(sfi, 90, 'security issue', locations_node_flags.STYLE1) >>> n.get_end_col() 0
-
get_end_line()¶ Get the end line from a
locations_node.Return type: int Returns: The node’s end line. >>> sf = next(s for s in project.current().sfiles() if s.name().endswith('apitest.cpp')) >>> sfi = sf.arbitrary_instance() >>> n = locations_node(sfi, 90, 'security issue', locations_node_flags.STYLE1) >>> n.get_end_line() 90
-
get_event()¶ Get the event string from a
locations_node.Return type: str Returns: The node’s event string. >>> sf = next(s for s in project.current().sfiles() if s.name().endswith('apitest.cpp')) >>> sfi = sf.arbitrary_instance() >>> n = locations_node(sfi, 90, 'security issue', locations_node_flags.STYLE1) >>> n.get_event() 'security issue'
-
get_file()¶ Get the file instance from a
locations_node.Return type: sfileinstReturns: The node’s file instance ( sfileinst).>>> sf = next(s for s in project.current().sfiles() if s.name().endswith('apitest.cpp')) >>> sfi = sf.arbitrary_instance() >>> n = locations_node(sfi, 90, 'security issue', locations_node_flags.STYLE1) >>> n.get_flags() <cs.locations_node_flags style1>
-
get_flags()¶ Get the flags from a
locations_node.Return type: locations_node_flagsReturns: The node’s flags. >>> sf = next(s for s in project.current().sfiles() if s.name().endswith('apitest.cpp')) >>> sfi = sf.arbitrary_instance() >>> n = locations_node(sfi, 90, 'security issue', locations_node_flags.STYLE1) >>> n.get_flags() <cs.locations_node_flags style1>
-
get_start_col()¶ Get the start column from a
locations_node.Return type: int Returns: The node’s starting column. >>> sf = next(s for s in project.current().sfiles() if s.name().endswith('apitest.cpp')) >>> sfi = sf.arbitrary_instance() >>> n = locations_node(sfi, 90, 'security issue', locations_node_flags.STYLE1) >>> n.get_start_col() 0
-
get_start_line()¶ Get the start line from a
locations_node.Return type: int Returns: The node’s start line. >>> sf = next(s for s in project.current().sfiles() if s.name().endswith('apitest.cpp')) >>> sfi = sf.arbitrary_instance() >>> n = locations_node(sfi, 90, 'security issue', locations_node_flags.STYLE1) >>> n.get_start_line() 90
-