Showing 2,674 of 2,674 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
<DndProvider backend={isTouchDevice ? TouchBackend : HTML5Backend}>
{selectedDeviceFeaturesOptions.map((selectedDeviceFeature, index) => (
<DeviceRow
selectedDeviceFeature={selectedDeviceFeature}
updateDeviceFeatureName={updateDeviceFeatureName}
- 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 60.
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
closeTagFilterDropdown = e => {
if (this.dropdownRef && this.dropdownRef.contains(e.target)) {
return;
}
this.setState({ tagFilterDropdownOpened: false });
- 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 60.
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
<tbody>
{ipMasks.map((mask, maskIndex) => (
<LANManagerIPLine
ipMask={mask}
disabled={disabled}
- 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 60.
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 EdfTempoService
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function EdfTempoService(gladys, serviceId) {
const dayjs = require('dayjs');
const axios = require('axios').default;
const utc = require('dayjs/plugin/utc');
const timezone = require('dayjs/plugin/timezone');
Function convertFeature
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function convertFeature(tuyaFunctions, externalId) {
const { code, values, name, readOnly } = tuyaFunctions;
const featuresCategoryAndType = mappings[code];
if (!featuresCategoryAndType) {
Function poll
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function poll(device) {
const externalId = device.external_id;
const [prefix, topic] = device.external_id.split(':');
if (prefix !== 'melcloud') {
Function onReportState
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function onReportState(body) {
const deviceSelector = get(body, 'directive.endpoint.endpointId');
const device = this.gladys.stateManager.get('device', deviceSelector);
if (!device) {
throw new NotFoundError(`Device "${deviceSelector}" not found`);
Function checkBatteries
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function checkBatteries() {
const enabled = await this.variable.getValue(SYSTEM_VARIABLE_NAMES.DEVICE_BATTERY_LEVEL_WARNING_ENABLED);
if (!enabled) {
return;
}
Function add
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function add(device) {
this.stateManager.setState('device', device.selector, device);
this.stateManager.setState('deviceByExternalId', device.external_id, device);
this.stateManager.setState('deviceById', device.id, device);
device.features.forEach((feature) => {
Function login
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
async login(state, e) {
if (e) {
e.preventDefault();
}
if (!validateEmail(state.loginFormEmailValue)) {
Function componentWillMount
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
async componentWillMount() {
let { deviceSelector } = this.props;
let device;
await Promise.all([this.props.getIntegrationByName(this.props.integrationName), this.props.getHouses()]);
Function render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render(props) {
return (
<div class="row g-2 mb-2">
<div class="col-5">
<Localizer>
Function render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render(props, { selectedDeviceFeaturesOptions, deviceOptions, loading, room }) {
const roomName = room && room.name;
return (
<BaseEditBox {...props} titleKey="dashboard.boxTitle.devices-in-room" titleValue={roomName}>
<div class={loading ? 'dimmer active' : 'dimmer'}>
Function createDevice
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
const createDevice = (networkAddress, serviceId, username, password) => {
const externalId = `tasmota:${networkAddress}`;
const device = {
name: networkAddress,
external_id: externalId,
Function scanPresence
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function scanPresence() {
const devices = await this.gladys.device.get({
service: 'lan-manager',
device_feature_category: DEVICE_FEATURE_CATEGORIES.PRESENCE_SENSOR,
});
Function up
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('t_device_feature_state', {
id: {
allowNull: false,
primaryKey: true,
Function WeatherController
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function WeatherController(gladys) {
/**
* @api {get} /api/v1/user/:user_selector/weather get weather user
* @apiName getWeatherUser
* @apiGroup Weather
Function associate
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
User.associate = (models) => {
User.hasMany(models.Location, {
foreignKey: 'user_id',
sourceKey: 'id',
as: 'locations',
Function transformDevice
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function transformDevice(device) {
const { mac, hostname, ip, vendor } = device;
const deviceExternalId = `lan-manager:${mac.replaceAll(':', '').toLowerCase()}`;
const params = [];
Function downloadBackup
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function downloadBackup(fileUrl) {
const encryptKey = await this.variable.getValue('GLADYS_GATEWAY_BACKUP_KEY');
if (encryptKey === null) {
throw new NotFoundError('GLADYS_GATEWAY_BACKUP_KEY_NOT_FOUND');
}