Metamation Developer Notes

  • Developer Notes
  • Resource Map
  • Tools
    • Code Formatting
    • Configuring Git
    • Assignments
    • Testing with Windows Sandbox
    • Single Binary Applications
    • Self-Updating Applications
  • Flux Workflow
    • Flux Workflow
    • Flux Development Style Guide
    • Release notes for Flux
    • SonarCloud analysis for Flux
    • Build a Flux SDK Program
    • Shipping Flux
    • Flux.Test
      • BasicBendAuto Test
      • LaserAuto.cs Detailed Documentation
      • Laserexample:Test1
  • Technical Notes
    • File formats
      • .FX File Format
      • Au(Gold) streams
      • .GEO File Format
      • .LST File Format
      • .LST file - technology
      • .BNC File Format
      • .WAD Files: Flux Resource Packages
      • .Curl Files: ASCII config information
    • Folders App
      • Data\Bendtools
      • Data\Machines
    • FluxCode
      • Welcome & Repo Map
      • Architecture & System Context
      • Subsystem *Bend* (Press Brake)
      • Subsystem *BCell* (Bend Cell Automation)
      • API Maps
      • Data Model Catalog
      • Design Patterns -- A Reader's Guide
      • Tests and Golden Paths
      • Guided Code Tours
      • CAM Glossary with Code Mapping
      • Assignments
      • Flux Onboarding Handbook
    • Data flow
      • Part
        • Part.Dwg
        • Part.Load
        • Part.Load to Part.Dwg
      • BendTech.cs
      • Bend Technology
      • Laser Cutting Technology
    • LTS (Long term support mechanism)
    • Machine ID Scheme
  • FluxTester
    • Commands and Scripts
    • Command Cookbook
    • Script Commands
    • BendTooling.cs Test Inventory
    • LaserTooling.cs Test Steps
    • Fluxtester Recipe Book
    • Nesting.cs Overview
    • Nesting.cs Recipe Book
    • Job.cs Overview
    • Job.cs Recipe Book
  • Software license
  • 3d party software
    • Python
  • Documentation
    • Bento documentation
      • Structure of a Bento page
      • Attributes
    • Software
      • Software Requirement
      • Installation
      • Git workflow for documentation contributors
    • Quick start guide
    • Workflow
      • Roles and responsibilities
      • Analyze
      • Edit
      • Proofread
      • Pre-Publish
      • Publish
      • Release cycle
      • Information required for Documentation Team
      • Checklist for Documenters
    • Styleguide
    • Flavoring
    • Translation
      • Ordering translation for a new document
    • Citations
    • Annotation
Flux Workflow
/
SonarCloud analysis for Flux

SonarCloud analysis for Flux

This document explains the SonarCloud analysis we are doing for Flux.

Rules that are turned off for now.

The following rules have been temporarily turned off, and we will need to re-enable them one by one as we clean up the code.

S3925: "ISerialiable" should be implemented correctly

In general, we don’t use the .Net serialization mechanisms directly in our code. However, any Custom Exception types we implement need to implement ISerializable if they are to be correctly marshalled across app-domains. This will become more important if we build some WebServices that use the Flux API. See Custom Exceptions for an implementation pattern.

S2365: Properties should not make collections or array copies

This happens about 150 times in the code. After analysis, I found a few places where the performance might be improved. But mostly we are using this to return small collections (like the set of installed tool catalogs etc) that have a few dozen members at most.

Besides, half of these issues happen in the Flux.API where this would be a breaking change. For now, I have turned this off, and we might re-enable later and selectively fix only the cases in Flux.Core, and leave the Flux.API intact.

S1133: Deprecated code should be removed

Code marked with [Obsolete] should be removed - we use this mainly in Flux.API to clients of the API a heads-up before removing some methods / properties. However, we want to give them a 6-month grace time for removal, during which this code-smell would be annoying. So I turned this off.

Usages of the [Obsolete] attribute in Flux.API are each tagged with a remove-by date, so we can periodically (say once a month) revisit them and remove those that have finished their 6-month warning cycle.

Rules that are turned off permanently

These rules are turned off in the 'metamation' profile, and I don’t intend that we will turn them on again.

S2696: Instance methods should not update static fields

There are a lot of places where we use static fields to store UI state (like whether a collapsible section is open or not, the position of a particular editing panel on the screen etc). This state is also sometimes persisted across sessions (by the Flux PStatic mechanism). Such UI code is inherently single threaded, and the danger of updating the same static from different locations does not arise. So this rule should be turned off.

S907: Goto statements should not be used

Disagree. Sometimes, a goto statement is the cleanest way to write the code.

S2344: Enumeration types should not have Flags or Enum suffixes

Disagree.

S1066: Collapsible 'if' statements should be merged

Sometimes, a single if statement with a lot of clauses merged with && is more complicated to read and parse than a pair of nested if statements:

  if (machine is ...)
     if (bend is ...)
        bend.ProcessOnMachine ()

S3010: Don’t initialize a static field in a constructor

This is used a lot in Flux to implement a singleton pattern. For example, since there is exactly one instance of the Flux.Application class, the constructor of Flux.Application does an assignment to the static Flux.Application.It field:

   It = this;

This is a common and well established pattern we use in many places. This is SonarCloud being too paranoid.

S2376: Write-only properties should not be used

There are situations where we like to use this kind of write-only property in Flux.

Rules that SonarCloud gets wrong consistently

The implementation of these rules seems to be defective - SonarCloud’s flow analysis is not good enough to detect if the error is actual, or a false alarm and it confidently asserts an error when a simple inspection would show the error is spurious.

Though these rules might sometimes catch a real problem, I am going to turn them off for Flux, because a few false alarms tend to build an overall sense of distrust about the whole system.

S4158: Empty collections should not be accessed or iterated

Contents

  • Rules that are turned off for now.
  • S3925: "ISerialiable" should be implemented correctly
  • S2365: Properties should not make collections or array copies
  • S1133: Deprecated code should be removed
  • Rules that are turned off permanently
  • S2696: Instance methods should not update static fields
  • S907: Goto statements should not be used
  • S2344: Enumeration types should not have Flags or Enum suffixes
  • S1066: Collapsible 'if' statements should be merged
  • S3010: Don’t initialize a static field in a constructor
  • S2376: Write-only properties should not be used
  • Rules that SonarCloud gets wrong consistently
  • S4158: Empty collections should not be accessed or iterated
Release notes for Flux Build a Flux SDK Program

      Copyright © 2025 TRUMPF Metamation. All rights reserved.

    Compiled by Bento