Showing 40 of 40 total issues
Function updateStats
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
const updateStats = () => {
Object.keys(subscribers).forEach((subscriberId) => {
const subscriberStats = subscribers[subscriberId];
const { subscriber, lastStats, lastLastStats } = subscriberStats;
subscriber.getStats((err, stats) => {
Function NotificationService
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function NotificationService($window, OTSession, Push) {
let focused = true;
$window.addEventListener('blur', () => {
focused = false;
- 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 PublisherStatsDirective
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function PublisherStatsDirective(OTSession, $interval) {
function link(scope) {
let currentPublisher;
const allLastStats = {};
let currentInterval;
- 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 NotificationService
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function NotificationService($window, OTSession, Push) {
let focused = true;
$window.addEventListener('blur', () => {
focused = false;
Function RoomCtrl
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function RoomCtrl($scope, $http, $window, $document, $timeout, OTSession, RoomService, baseURL, NotificationService) {
$scope.streams = OTSession.streams;
$scope.connections = OTSession.connections;
$scope.publishing = false;
$scope.archiveId = null;
- 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 link
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
function link(scope, element) {
let currentPublisher;
scope.devices = [];
scope.showDeviceList = false;
scope.selectedLabel = '';
Function MicrophonePickerDirective
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function MicrophonePickerDirective() {
function link(scope, element) {
let currentPublisher;
scope.devices = [];
scope.showDeviceList = false;
- 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 toggleFilterList
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
scope.toggleFilterList = () => {
scope.showFilterList = !scope.showFilterList;
setTimeout(() => {
// Do it asynchronously so we don't block
Function mappedStats
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
const mappedStats = allStats.map((statsContainer) => {
const { stats } = statsContainer;
const key = statsContainer.subscriberId || 'Mantis';
if (!allLastStats[key]) {
Function subscriberStats
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
'$timeout', function subscriberStats(OTSession, StatsService, $timeout) {
return {
restrict: 'E',
scope: {
stream: '=',
Function mutePublisher
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
.directive('mutePublisher', ['OTSession', function mutePublisher(OTSession) {
return {
restrict: 'A',
link(scope, element, attrs) {
const type = attrs.mutedType || 'Video';
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (winWidth - element.width() < parseInt(element.css('left'), 10)) {
// We're too narrow, switch to being right aligned
element.css({
left: 'auto',
right: '10px',
- 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 59.
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
if (winHeight - element.height() < parseInt(element.css('top'), 10)) {
// We're too short switch to being bottom aligned
element.css({
top: 'auto',
bottom: '10px',
- 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 59.
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 link
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
link(scope, element, attrs) {
const type = attrs.mutedType || 'Video';
scope[`muted${type}`] = false;
const getPublisher = () =>
Function json
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
json() {
const goToRoom = (err, sessionId, pApiKey, pSecret) => {
if (err) {
console.error('Error getting room: ', err);
res.send({
Function mutePublisher
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
.directive('mutePublisher', ['OTSession', function mutePublisher(OTSession) {
return {
restrict: 'A',
link(scope, element, attrs) {
const type = attrs.mutedType || 'Video';
- 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 filteredPublisher
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function filteredPublisher(OTSession, $rootScope) {
return {
restrict: 'E',
scope: {
props: '&',
- 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 MainCtrl
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
.controller('MainCtrl', ['$scope', '$window', function MainCtrl($scope, $window) {
$scope.room = '';
$scope.roomType = 'normal';
$scope.advanced = false;
$scope.joinRoom = () => {
- 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 restrictFrameRate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
.directive('restrictFramerate', ['OTSession', function restrictFrameRate(OTSession) {
return {
restrict: 'E',
template: '<button class="restrict-framerate-btn" ng-class="' +
'{\'ion-ios7-speedometer-outline\': restrictedFrameRate, ' +
- 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 draggable
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function draggable($document, $window) {
const getEventProp = (event, prop) => {
if (event[prop] === 0) return 0;
return event[prop] || (event.touches && event.touches[0][prop]) ||
(event.originalEvent && event.originalEvent.touches &&
- 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"