Showing 3,654 of 3,654 total issues
Function UsersService
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function UsersService(api, $q, notify) {
var usersService: any = {};
usersService.usernamePattern = /^[A-Za-z0-9_.'-]+$/;
usersService.phonePattern = /^(?:(?:0?[1-9][0-9]{8})|(?:(?:\+|00)[1-9][0-9]{9,11}))$/;
Function publish
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
$scope.publish = function() {
$scope.$applyAsync(() => {
$scope.loading = true;
});
Function render
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const {item} = this.props;
const thumbnail = getViewImage(item);
const showFigure = thumbnail != null && thumbnail.mimetype.startsWith('image');
Function render
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
return (
<Modal
visible
zIndex={1050}
Function constructor
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor($location, superdeskFlags, authoring, suggest, $rootScope, search, $window) {
this.$location = $location;
this.superdeskFlags = superdeskFlags;
this.authoring = authoring;
this.suggest = suggest;
Function MetadropdownFocusDirective
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function MetadropdownFocusDirective(keyboardManager) {
return {
require: 'dropdown',
link: function(scope, elem, attrs, dropdown) {
scope.$watch(dropdown.isOpen, (isOpen) => {
Function render
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
return (
<div>
{this.props.mediaItems.map((item, index) => (
<div key={item._id}>
Function link
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
link: function(scope, elem) {
var open = false;
elem.bind('click', (event) => {
if (!open) {
Function ExtensionPointDirective
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function ExtensionPointDirective(extensionPoints, _, $q) {
function _buildCompoment(extension, scope) {
// for easy access put values from parent scope into ...
const callback = extension.onInit && extension.onInit(extension, scope) || $q.resolve();
Function render
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
if (this.props.loading || this.props.itemIds == null) {
return <div className="item-group__loading" />;
}
Function PhotoDeskInfo
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const PhotoDeskInfo: React.StatelessComponent<IProps> = (props) => {
const {item} = props;
const datetime = ng.get('datetime');
Function SavedSearchService
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function SavedSearchService(api, $filter, $q, $rootScope) {
var _getAll = function(endPoint, page = 1, items = [], params = null) {
return api.query(endPoint, {max_results: 200, page: page}, params)
.then((result) => {
let pg = page;
Function getDraftCharacterListForSelection
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function getDraftCharacterListForSelection(
editorState: EditorState,
selection: SelectionState,
): List<CharacterMetadata> {
// including all blocks
Function manageEmbeds
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
manageEmbeds(__html: string): string {
let html = __html;
const embedCount = html.match(/<!-- EMBED START.*-->/g)?.length ?? 0;
for (let i = 0; i < embedCount; i++) {
Function fetchChangedResources
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function fetchChangedResources<T extends IBaseRestApiResponse>(
resource: string,
changes: Array<IResourceChange>,
currentItems: Array<T>,
refreshAllOnFieldsChange: Set<string> = new Set(),
Function constructor
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor() {
this.scope = {};
this.controllerAs = 'vm';
this.controller = [
'$element',
Function mediaQuery
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function mediaQuery($window, authoringWorkspace: AuthoringWorkspaceService) {
return {
scope: {
minWidth: '=',
maxWidth: '=',
Function applyStyleSuggestion
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function applyStyleSuggestion(editorState, type, style, data) {
const selection = editorState.getSelection();
let newEditorState = editorState;
let tmpEditorState;
let currentStyle;
Function constructor
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor() {
var self = this;
this.dropDown = element(by.id('ingest-dashboard-dropdown'));
this.ingestDashboard = element(by.css('.ingest-dashboard-list'));
Similar blocks of code found in 3 locations. Consider refactoring. Open
<a
className="image-block__image-action"
data-sd-tooltip={gettext('Edit metadata')}
onClick={() => {
this.onClick('view');
- 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 64.
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