CLI: make ERC report include violations with the expected severities

the ERC report creates its own SHEETLIST_ERC_ITEMS_PROVIDER and
hard-codes warnings and errors as wanted severities, regardless
of the --severity-* options given through the CLI.

we keep the marker provider optional and create a fallback instance for
tests code that expects reports with warnings and errors.
This commit is contained in:
Bernhard Kirchen
2025-11-23 16:05:15 +00:00
committed by Mark Roszko
parent 30bfd0459b
commit 24dec03ba5
3 changed files with 19 additions and 14 deletions
+1 -1
View File
@@ -1183,7 +1183,7 @@ int EESCHEMA_JOBS_HANDLER::JobSchErc( JOB* aJob )
m_reporter->Report( wxString::Format( _( "Found %d violations\n" ), markersProvider->GetCount() ),
RPT_SEVERITY_INFO );
ERC_REPORT reportWriter( sch, units );
ERC_REPORT reportWriter( sch, units, markersProvider );
bool wroteReport = false;
+15 -12
View File
@@ -35,10 +35,19 @@
#include <rc_json_schema.h>
ERC_REPORT::ERC_REPORT( SCHEMATIC* aSchematic, EDA_UNITS aReportUnits ) :
ERC_REPORT::ERC_REPORT( SCHEMATIC* aSchematic, EDA_UNITS aReportUnits,
std::shared_ptr<RC_ITEMS_PROVIDER> aMarkersProvider ) :
m_sch( aSchematic ),
m_reportUnits( aReportUnits )
m_reportUnits( aReportUnits ),
m_markersProvider( std::move( aMarkersProvider ) )
{
if( !m_markersProvider )
{
// When no provider is supplied, fall back to creating one with default severities.
// This allows test code to get a basic report without needing to set up a provider.
m_markersProvider = std::make_shared<SHEETLIST_ERC_ITEMS_PROVIDER>( m_sch );
m_markersProvider->SetSeverities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING );
}
}
@@ -63,14 +72,11 @@ wxString ERC_REPORT::GetTextReport()
ERC_SETTINGS& settings = m_sch->ErcSettings();
SHEETLIST_ERC_ITEMS_PROVIDER errors( m_sch );
errors.SetSeverities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING );
std::map<SCH_SHEET_PATH, std::vector<ERC_ITEM*>> orderedItems;
for( int i = 0; i < errors.GetCount(); ++i )
for( int i = 0; i < m_markersProvider->GetCount(); ++i )
{
if( auto item = dynamic_cast<ERC_ITEM*>( errors.GetItem( i ).get() ) )
if( auto item = dynamic_cast<ERC_ITEM*>( m_markersProvider->GetItem( i ).get() ) )
{
if( item->MainItemHasSheetPath() )
orderedItems[item->GetMainItemSheetPath()].emplace_back( item );
@@ -141,14 +147,11 @@ bool ERC_REPORT::WriteJsonReport( const wxString& aFullFileName )
ERC_SETTINGS& settings = m_sch->ErcSettings();
SHEETLIST_ERC_ITEMS_PROVIDER errors( m_sch );
errors.SetSeverities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING );
std::map<SCH_SHEET_PATH, std::vector<ERC_ITEM*>> orderedItems;
for( int i = 0; i < errors.GetCount(); ++i )
for( int i = 0; i < m_markersProvider->GetCount(); ++i )
{
if( auto item = dynamic_cast<ERC_ITEM*>( errors.GetItem( i ).get() ) )
if( auto item = dynamic_cast<ERC_ITEM*>( m_markersProvider->GetItem( i ).get() ) )
{
if( item->MainItemHasSheetPath() )
orderedItems[item->GetMainItemSheetPath()].emplace_back( item );
+3 -1
View File
@@ -30,7 +30,8 @@ class RC_ITEMS_PROVIDER;
class ERC_REPORT
{
public:
ERC_REPORT( SCHEMATIC* aSchematic, EDA_UNITS aReportUnits );
ERC_REPORT( SCHEMATIC* aSchematic, EDA_UNITS aReportUnits,
std::shared_ptr<RC_ITEMS_PROVIDER> aMarkersProvider = nullptr );
/**
* Returns the ERC report in "text" (human readable) format in the C-locale.
@@ -56,6 +57,7 @@ public:
private:
SCHEMATIC* m_sch;
EDA_UNITS m_reportUnits;
std::shared_ptr<RC_ITEMS_PROVIDER> m_markersProvider;
};