Showing 1,111 of 1,370 total issues
Function createLocalPageObservable
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private createLocalPageObservable(
pagination$: Observable<PaginationEntityState>,
schema: normalizrSchema.Entity,
fetching$: Observable<boolean>
) {
Function ngOnInit
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
ngOnInit() {
this.isOrgRole = !this.spaceGuid;
const users$ = this.store.select(selectCfUsersRolesPicked);
// If setting an org role user must be admin or org manager.
// If setting a space role user must be admin, org manager or space manager
Function constructor
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(dir: string, options?: any, loggingEnabled = true) {
this.angularJsonFile = this.findFileOrFolderInChain(dir, 'angular.json');
this.angularJson = JSON.parse(fs.readFileSync(this.angularJsonFile, 'utf8').toString());
this.loggingEnabled = loggingEnabled;
Function hasUpgrade
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public hasUpgrade(returnLatest = false): Observable<InternalHelmUpgrade> {
const updates = combineLatest(this.getCharts(), this.release$);
return updates.pipe(
map(([charts, release]) => {
let score = -1;
Method MetricsSpecification.getMetricsEndpoints
has 65 lines of code (exceeds 50 allowed). Consider refactoring. 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)
Function processSingleItemDeleteAction
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private processSingleItemDeleteAction<T extends BasicKubeAPIResource>(action: KubeAction, url: string) {
this.store.dispatch(new StartRequestAction(action, 'delete'));
const headers = new HttpHeaders({
'x-cap-cnsi-list': action.kubeGuid,
'x-cap-passthrough': 'true'
Function constructor
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(
private store: Store<AppState>,
paginationMonitorFactory: PaginationMonitorFactory,
entityMonitorFactory: EntityMonitorFactory,
internalEventMonitorFactory: InternalEventMonitorFactory,
Similar blocks of code found in 2 locations. Consider refactoring. Open
describe('KubernetesGKEAuthFormComponent', () => {
let component: KubernetesGKEAuthFormComponent;
let fixture: ComponentFixture<KubernetesGKEAuthFormComponent>;
beforeEach(async(() => {
- 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 222.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
describe('KubernetesConfigAuthFormComponent', () => {
let component: KubernetesConfigAuthFormComponent;
let fixture: ComponentFixture<KubernetesConfigAuthFormComponent>;
beforeEach(async(() => {
- 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 222.
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
Method CFAppPush.deploy
has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring. Open
func (cfAppPush *CFAppPush) deploy(echoContext echo.Context) error {
cnsiGUID := echoContext.Param("cnsiGuid")
orgGUID := echoContext.Param("orgGuid")
spaceGUID := echoContext.Param("spaceGuid")
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Analyzer.deleteEndpoint
has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring. Open
func (a *Analyzer) deleteEndpoint(ec echo.Context) error {
log.Debug("delete reports for endpoint")
endpoint := ec.Param("endpoint")
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Analysis.OnEndpointNotification
has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring. Open
func (analysis *Analysis) OnEndpointNotification(action interfaces.EndpointAction, endpoint *interfaces.CNSIRecord) {
if action == interfaces.EndpointUnregisterAction {
// An endpoint was unregistered, so remove all reports
dbStore, err := store.NewAnalysisDBStore(analysis.portalProxy.GetDatabaseConnection())
if err == nil {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method portalProxy.RefreshOidcToken
has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring. Open
func (p *portalProxy) RefreshOidcToken(skipSSLValidation bool, cnsiGUID, userGUID, client, clientSecret, tokenEndpoint string) (t interfaces.TokenRecord, err error) {
log.Debug("RefreshOidcToken")
userToken, ok := p.GetCNSITokenRecordWithDisconnected(cnsiGUID, userGUID)
if !ok {
return t, fmt.Errorf("Info could not be found for user with GUID %s", userGUID)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method ConsoleConfigRepository.GetConsoleConfig
has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring. Open
func (c *ConsoleConfigRepository) GetConsoleConfig() (*interfaces.ConsoleConfig, error) {
log.Debug("Get ConsoleConfig")
rows, err := c.db.Query(getConsoleConfig)
if err != nil {
return nil, fmt.Errorf("Unable to retrieve console config record: %v", err)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method TokenStore.FindCNSIToken
has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring. Open
func (d *TokenStore) FindCNSIToken(cnsiGUID string, userGUID string, encryptionKey []byte) (interfaces.TokenRecord, error) {
// Main method that we need to override to get the token for the given endpoint
local, err := ListCloudFoundry()
if err == nil {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function ApplyMigrations
has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring. Open
func ApplyMigrations(conf *goose.DBConf, db *sql.DB) error {
current, err := goose.EnsureDBVersion(conf, db)
if err != nil {
return fmt.Errorf("Failed to get database version: %s", err.Error())
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function MigrateSetupData
has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring. Open
func MigrateSetupData(portal interfaces.PortalProxy, configStore Repository) error {
// Determine if we need to migrate data first
_, ok, err := configStore.GetValue(systemGroupName, configSetupNeededMarker)
if err != nil {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method KubeConfigFile.GetUserForCluster
has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring. Open
func (k *KubeConfigFile) GetUserForCluster(clusterEndpoint string) (*KubeConfigUser, error) {
var cluster *KubeConfigCluster
var err error
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function paginate
has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring. Open
function paginate(action, state: PaginationState = {}, updatePagination) {
if (action.type === ApiActionTypes.API_REQUEST_START) {
return state;
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function update
has a Cognitive Complexity of 16 (exceeds 8 allowed). Consider refactoring. Open
private update() {
this.initials = null;
this.gravatar = null;
const user = this.userInfo;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"