Showing 1,111 of 1,370 total issues
Method PostgresCNSIRepository.List
has 6 return statements (exceeds 4 allowed). Open
func (p *PostgresCNSIRepository) List(encryptionKey []byte) ([]*interfaces.CNSIRecord, error) {
log.Debug("List")
rows, err := p.db.Query(listCNSIs)
if err != nil {
return nil, fmt.Errorf("Unable to retrieve CNSI records: %v", err)
Method PostgresCNSIRepository.Update
has 6 return statements (exceeds 4 allowed). Open
func (p *PostgresCNSIRepository) Update(endpoint interfaces.CNSIRecord, encryptionKey []byte) error {
log.Debug("Update endpoint")
if endpoint.GUID == "" {
msg := "Unable to update Endpoint without a valid guid."
Method PgsqlTokenRepository.FindAllCNSITokenBackup
has 6 return statements (exceeds 4 allowed). Open
func (p *PgsqlTokenRepository) FindAllCNSITokenBackup(cnsiGUID string, encryptionKey []byte) ([]interfaces.BackupTokenRecord, error) {
log.Debug("FindAllCNSITokenBackup")
if cnsiGUID == "" {
msg := "Unable to find CNSI Token without a valid CNSI GUID."
log.Debug(msg)
Consider simplifying this complex logical expression. Open
if (isAdmin) {
const allCfUsersAction = this.createCfGetAllUsersAction(cfGuid);
if (!orgGuid) {
return observableOf(allCfUsersAction);
Consider simplifying this complex logical expression. Open
if (!secrets ||
!secrets.consoleUsers || !secrets.consoleUsers.admin || !secrets.consoleUsers.nonAdmin ||
!secrets.endpoints || !secrets.endpoints.cf
) {
throw new Error(`Failed to validate secrets`);
Similar blocks of code found in 2 locations. Consider refactoring. Open
package analysis
import (
"database/sql"
"strings"
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 210.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Consider simplifying this complex logical expression. Open
if (ep.provider && ep.provider.metadata && ep.provider.metadata && ep.provider.metadata.metrics_stratos
&& Array.isArray(ep.provider.metadata.metrics_stratos)) {
ep.provider.metadata.metrics_stratos.forEach(endp => {
// See if we already know about this endpoint
const hasEndpoint = data.findIndex(i => compareUrl(i.url, endp.url) || compareUrl(i.url, endp.cfEndpoint)) !== -1;
Consider simplifying this complex logical expression. Open
if (dsEndpointType || onlyConnected) {
transformEntities.push((entities: EndpointModel[]) => {
return dsEndpointType || onlyConnected ? entities.filter(endpoint => {
return (!onlyConnected || endpoint.connectionStatus === 'connected') &&
(!dsEndpointType || endpoint.cnsi_type === dsEndpointType);
Similar blocks of code found in 2 locations. Consider refactoring. Open
package analysis
import (
"database/sql"
"strings"
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 210.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function start
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func start(config interfaces.PortalConfig, p *portalProxy, needSetupMiddleware bool, isUpgrade bool, envLookup *env.VarSet) error {
Function initSessionStore
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func initSessionStore(db *sql.DB, databaseProvider string, pc interfaces.PortalConfig, sessionExpiry int, env *env.VarSet) (HttpSessionStore, *sessions.Options, error) {
Function newPortalProxy
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func newPortalProxy(pc interfaces.PortalConfig, dcp *sql.DB, ss HttpSessionStore, sessionStoreOptions *sessions.Options, env *env.VarSet) *portalProxy {
Method portalProxy.login
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func (p *portalProxy) login(c echo.Context, skipSSLValidation bool, client string, clientSecret string, endpoint string) (uaaRes *interfaces.UAAResponse, u *interfaces.JWTUserTokenInfo, err error) {
Method portalProxy.DoProxySingleRequestWithToken
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func (p *portalProxy) DoProxySingleRequestWithToken(cnsiGUID string, token *interfaces.TokenRecord, method, requestURL string, headers http.Header, body []byte) (*interfaces.CNSIRequest, error) {
Function handleSessionError
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func handleSessionError(config interfaces.PortalConfig, c echo.Context, err error, doNotLog bool, msg string) error {
Function updatePermission
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
user: CfUser,
entityGuid: string,
isSpace: boolean,
permissionType: OrgUserRoleNames | SpaceUserRoleNames,
add = false) {
Method AzureKubeAuth.FetchToken
has 5 return statements (exceeds 4 allowed). Open
func (p *AzureKubeAuth) FetchToken(cnsiRecord interfaces.CNSIRecord, ec echo.Context) (*interfaces.TokenRecord, *interfaces.CNSIRecord, error) {
req := ec.Request()
// Need to extract the parameters from the request body
defer req.Body.Close()
Function fetchManifest
has 5 return statements (exceeds 4 allowed). Open
func fetchManifest(repoPath string, stratosProject StratosProject, clientWebSocket *websocket.Conn) (Applications, string, error) {
var manifest Applications
// Can be either manifest.yml or manifest.yaml
Method Monocular.artifactHubCacheChartFiles
has 5 return statements (exceeds 4 allowed). Open
func (m *Monocular) artifactHubCacheChartFiles(endpointID, repoName, repoURL, name, version, digest string) (string, error) {
// First look to see if there is a digest file
cacheFolder := path.Join(m.CacheFolder, endpointID, fmt.Sprintf("%s_%s_%s", repoName, name, version))
if hasDigestFile(cacheFolder, digest) {
Method MetricsSpecification.getMetricsEndpoints
has 5 return statements (exceeds 4 allowed). Open
func (m *MetricsSpecification) getMetricsEndpoints(userGUID string, cnsiList []string) (map[string]EndpointMetricsRelation, error) {
metricsProviders := make([]MetricsMetadata, 0)
endpointsMap := make(map[string]*interfaces.ConnectedEndpoint)
results := make(map[string]EndpointMetricsRelation)