You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by na...@apache.org on 2025/05/27 07:03:08 UTC
(incubator-devlake) branch #8452 created (now a223bf621)
This is an automated email from the ASF dual-hosted git repository.
narro pushed a change to branch #8452
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
at a223bf621 refactor(codequality): extend field size for CQ and SonarQube
This branch includes the following new commits:
new 111a68757 fix: increase cq_issuescomponent length to text
new a223bf621 refactor(codequality): extend field size for CQ and SonarQube
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(incubator-devlake) 01/02: fix: increase cq_issuescomponent length to text
Posted by na...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
narro pushed a commit to branch #8452
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 111a6875769651705a760119828c48e7c474f9d3
Author: abeizn <zi...@merico.dev>
AuthorDate: Thu Sep 19 09:59:36 2024 +0800
fix: increase cq_issuescomponent length to text
---
.../models/domainlayer/codequality/cq_issues.go | 2 +-
.../20240919_increase_cq_issue_component_length.go | 40 ++++++++++++++++++++++
backend/core/models/migrationscripts/register.go | 1 +
3 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/backend/core/models/domainlayer/codequality/cq_issues.go b/backend/core/models/domainlayer/codequality/cq_issues.go
index 243e675fa..1e9ea7134 100644
--- a/backend/core/models/domainlayer/codequality/cq_issues.go
+++ b/backend/core/models/domainlayer/codequality/cq_issues.go
@@ -26,7 +26,7 @@ type CqIssue struct {
domainlayer.DomainEntity
Rule string `gorm:"type:varchar(255)"`
Severity string `gorm:"type:varchar(100)"`
- Component string `gorm:"type:varchar(255)"`
+ Component string
ProjectKey string `gorm:"index;type:varchar(100)"` //domain project key
Line int
Status string `gorm:"type:varchar(20)"`
diff --git a/backend/core/models/migrationscripts/20240919_increase_cq_issue_component_length.go b/backend/core/models/migrationscripts/20240919_increase_cq_issue_component_length.go
new file mode 100644
index 000000000..aa1483e06
--- /dev/null
+++ b/backend/core/models/migrationscripts/20240919_increase_cq_issue_component_length.go
@@ -0,0 +1,40 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+ "github.com/apache/incubator-devlake/core/context"
+ "github.com/apache/incubator-devlake/core/errors"
+ "github.com/apache/incubator-devlake/core/plugin"
+)
+
+var _ plugin.MigrationScript = (*increaseCqIssueComponentLength)(nil)
+
+type increaseCqIssueComponentLength struct{}
+
+func (script *increaseCqIssueComponentLength) Up(basicRes context.BasicRes) errors.Error {
+ return basicRes.GetDal().ModifyColumnType("cq_issues", "component", "text")
+}
+
+func (*increaseCqIssueComponentLength) Version() uint64 {
+ return 20240919160242
+}
+
+func (*increaseCqIssueComponentLength) Name() string {
+ return "increase cq_issues.component length to text"
+}
diff --git a/backend/core/models/migrationscripts/register.go b/backend/core/models/migrationscripts/register.go
index 4886f66a4..191d0817b 100644
--- a/backend/core/models/migrationscripts/register.go
+++ b/backend/core/models/migrationscripts/register.go
@@ -136,5 +136,6 @@ func All() []plugin.MigrationScript {
new(addCqIssueImpacts),
new(addDueDateToIssues),
new(createQaTables),
+ new(increaseCqIssueComponentLength),
}
}
(incubator-devlake) 02/02: refactor(codequality): extend field size for CQ and SonarQube
Posted by na...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
narro pushed a commit to branch #8452
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit a223bf621246835cd39a08642d0a47ca372fbdc6
Author: narro wizard <co...@merico.dev>
AuthorDate: Tue May 27 07:02:53 2025 +0000
refactor(codequality): extend field size for CQ and SonarQube
- Increase CqFileMetrics.FileName to varchar(2000)
- Increase CqProject.Name to varchar(2000)
- Increase CqFileMetrics.Id to varchar(3000)
- Increase SonarqubeFileMetrics.FileMetricsKey to varchar(3000)
- Increase SonarqubeFileMetrics.FileName to varchar(2000)
These changes accommodate longer file names and identifiers in modern projects.
#8452
---
.../domainlayer/codequality/cq_file_metrics.go | 9 ++---
.../models/domainlayer/codequality/cq_projects.go | 2 +-
.../20250527_extend_field_size_for_cq.go} | 37 ++++++++++----------
backend/core/models/migrationscripts/register.go | 1 +
.../20250527_extend_field_size.go} | 39 +++++++++++-----------
.../sonarqube/models/migrationscripts/register.go | 1 +
.../sonarqube/models/sonarqube_file_metrics.go | 4 +--
7 files changed, 49 insertions(+), 44 deletions(-)
diff --git a/backend/core/models/domainlayer/codequality/cq_file_metrics.go b/backend/core/models/domainlayer/codequality/cq_file_metrics.go
index c83a79813..293d1a7ea 100644
--- a/backend/core/models/domainlayer/codequality/cq_file_metrics.go
+++ b/backend/core/models/domainlayer/codequality/cq_file_metrics.go
@@ -18,13 +18,14 @@ limitations under the License.
package codequality
import (
- "github.com/apache/incubator-devlake/core/models/domainlayer"
+ "github.com/apache/incubator-devlake/core/models/common"
)
type CqFileMetrics struct {
- domainlayer.DomainEntity
- ProjectKey string `gorm:"index;type:varchar(255)"` //domain project key
- FileName string `gorm:"type:varchar(255)"`
+ common.NoPKModel
+ Id string `json:"id" gorm:"primaryKey;type:varchar(3000);comment:This key is generated based on details from the original plugin"` // format: <Plugin>:<Entity>:<PK0>:<PK1>
+ ProjectKey string `gorm:"index;type:varchar(255)"` //domain project key
+ FileName string `gorm:"type:varchar(2000)"`
FilePath string
FileLanguage string `gorm:"type:varchar(20)"`
CodeSmells int
diff --git a/backend/core/models/domainlayer/codequality/cq_projects.go b/backend/core/models/domainlayer/codequality/cq_projects.go
index fe80dd1bb..d0f0be4d3 100644
--- a/backend/core/models/domainlayer/codequality/cq_projects.go
+++ b/backend/core/models/domainlayer/codequality/cq_projects.go
@@ -27,7 +27,7 @@ var _ plugin.Scope = (*CqProject)(nil)
type CqProject struct {
domainlayer.DomainEntityExtended
- Name string `gorm:"type:varchar(255)"`
+ Name string `gorm:"type:varchar(2000)"`
Qualifier string `gorm:"type:varchar(255)"`
Visibility string `gorm:"type:varchar(64)"`
LastAnalysisDate *common.Iso8601Time
diff --git a/backend/core/models/domainlayer/codequality/cq_projects.go b/backend/core/models/migrationscripts/20250527_extend_field_size_for_cq.go
similarity index 51%
copy from backend/core/models/domainlayer/codequality/cq_projects.go
copy to backend/core/models/migrationscripts/20250527_extend_field_size_for_cq.go
index fe80dd1bb..838eb6010 100644
--- a/backend/core/models/domainlayer/codequality/cq_projects.go
+++ b/backend/core/models/migrationscripts/20250527_extend_field_size_for_cq.go
@@ -15,33 +15,34 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package codequality
+package migrationscripts
import (
- "github.com/apache/incubator-devlake/core/models/common"
- "github.com/apache/incubator-devlake/core/models/domainlayer"
+ "github.com/apache/incubator-devlake/core/context"
+ "github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
)
-var _ plugin.Scope = (*CqProject)(nil)
+var _ plugin.MigrationScript = (*extendFieldSizeForCq)(nil)
-type CqProject struct {
- domainlayer.DomainEntityExtended
- Name string `gorm:"type:varchar(255)"`
- Qualifier string `gorm:"type:varchar(255)"`
- Visibility string `gorm:"type:varchar(64)"`
- LastAnalysisDate *common.Iso8601Time
- CommitSha string `gorm:"type:varchar(128)"`
-}
+type extendFieldSizeForCq struct{}
-func (CqProject) TableName() string {
- return "cq_projects"
+func (script *extendFieldSizeForCq) Up(basicRes context.BasicRes) errors.Error {
+ err := basicRes.GetDal().ModifyColumnType("cq_projects", "name", "varchar(2000)")
+ if err != nil {
+ return err
+ }
+ err = basicRes.GetDal().ModifyColumnType("cq_file_metrics", "file_name", "varchar(2000)")
+ if err != nil {
+ return err
+ }
+ return basicRes.GetDal().ModifyColumnType("cq_file_metrics", "id", "varchar(3000)")
}
-func (s *CqProject) ScopeId() string {
- return s.Id
+func (*extendFieldSizeForCq) Version() uint64 {
+ return 20250527000000
}
-func (s *CqProject) ScopeName() string {
- return s.Name
+func (*extendFieldSizeForCq) Name() string {
+ return "extend field size for cq"
}
diff --git a/backend/core/models/migrationscripts/register.go b/backend/core/models/migrationscripts/register.go
index 191d0817b..fd90c8fd2 100644
--- a/backend/core/models/migrationscripts/register.go
+++ b/backend/core/models/migrationscripts/register.go
@@ -137,5 +137,6 @@ func All() []plugin.MigrationScript {
new(addDueDateToIssues),
new(createQaTables),
new(increaseCqIssueComponentLength),
+ new(extendFieldSizeForCq),
}
}
diff --git a/backend/core/models/domainlayer/codequality/cq_projects.go b/backend/plugins/sonarqube/models/migrationscripts/20250527_extend_field_size.go
similarity index 52%
copy from backend/core/models/domainlayer/codequality/cq_projects.go
copy to backend/plugins/sonarqube/models/migrationscripts/20250527_extend_field_size.go
index fe80dd1bb..502a894cd 100644
--- a/backend/core/models/domainlayer/codequality/cq_projects.go
+++ b/backend/plugins/sonarqube/models/migrationscripts/20250527_extend_field_size.go
@@ -15,33 +15,34 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-package codequality
+package migrationscripts
import (
- "github.com/apache/incubator-devlake/core/models/common"
- "github.com/apache/incubator-devlake/core/models/domainlayer"
+ "github.com/apache/incubator-devlake/core/context"
+ "github.com/apache/incubator-devlake/core/errors"
"github.com/apache/incubator-devlake/core/plugin"
)
-var _ plugin.Scope = (*CqProject)(nil)
+var _ plugin.MigrationScript = (*extendSonarqubeFieldSize)(nil)
-type CqProject struct {
- domainlayer.DomainEntityExtended
- Name string `gorm:"type:varchar(255)"`
- Qualifier string `gorm:"type:varchar(255)"`
- Visibility string `gorm:"type:varchar(64)"`
- LastAnalysisDate *common.Iso8601Time
- CommitSha string `gorm:"type:varchar(128)"`
-}
+type extendSonarqubeFieldSize struct{}
-func (CqProject) TableName() string {
- return "cq_projects"
+func (script *extendSonarqubeFieldSize) Up(basicRes context.BasicRes) errors.Error {
+ db := basicRes.GetDal()
+
+ err := db.ModifyColumnType("_tool_sonarqube_file_metrics", "file_metrics_key", "varchar(3000)")
+ if err != nil {
+ return err
+ }
+
+ err = db.ModifyColumnType("_tool_sonarqube_file_metrics", "file_name", "varchar(2000)")
+ return err
}
-func (s *CqProject) ScopeId() string {
- return s.Id
+func (*extendSonarqubeFieldSize) Version() uint64 {
+ return 20250527000000
}
-func (s *CqProject) ScopeName() string {
- return s.Name
-}
+func (*extendSonarqubeFieldSize) Name() string {
+ return "extend field size for sonarqube file metrics"
+}
\ No newline at end of file
diff --git a/backend/plugins/sonarqube/models/migrationscripts/register.go b/backend/plugins/sonarqube/models/migrationscripts/register.go
index 849f11248..7c48de842 100644
--- a/backend/plugins/sonarqube/models/migrationscripts/register.go
+++ b/backend/plugins/sonarqube/models/migrationscripts/register.go
@@ -38,5 +38,6 @@ func All() []plugin.MigrationScript {
new(increaseProjectKeyLength),
new(addOrgToConn),
new(addIssueImpacts),
+ new(extendSonarqubeFieldSize),
}
}
diff --git a/backend/plugins/sonarqube/models/sonarqube_file_metrics.go b/backend/plugins/sonarqube/models/sonarqube_file_metrics.go
index a7acef9c1..c064e2679 100644
--- a/backend/plugins/sonarqube/models/sonarqube_file_metrics.go
+++ b/backend/plugins/sonarqube/models/sonarqube_file_metrics.go
@@ -23,9 +23,9 @@ import (
type SonarqubeFileMetrics struct {
ConnectionId uint64 `gorm:"primaryKey"`
- FileMetricsKey string `gorm:"primaryKey;type:varchar(500)"`
+ FileMetricsKey string `gorm:"primaryKey;type:varchar(3000)"`
ProjectKey string `gorm:"index"`
- FileName string
+ FileName string `gorm:"type:varchar(2000)"`
FilePath string
FileLanguage string
CodeSmells int